Skip to content

Commit

Permalink
Merge pull request #12 from YevhenBondarenko/feature/java-21
Browse files Browse the repository at this point in the history
added openjdk 21
  • Loading branch information
ashvayka authored Mar 13, 2024
2 parents 84c5f1a + 7e4f965 commit 10e0a23
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 0 deletions.
57 changes: 57 additions & 0 deletions openjdk21/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# Copyright © 2016-2020 The Thingsboard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

FROM ${docker.repo}/base:${debian.codename}

# Default to UTF-8 file.encoding
ENV LANG C.UTF-8
ENV JAVA_HOME /docker-java-home
ENV JAVA_VERSION 21.0.2
ENV JAVA_DEBIAN_VERSION 21.0.2+13-2

# Remove when stable version is available
RUN echo "deb http://deb.debian.org/debian trixie main" > /etc/apt/sources.list.d/trixie.list

RUN apt-get update && apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
&& { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home \
&& ln -svT "/usr/lib/jvm/java-21-openjdk-$(dpkg --print-architecture)" /docker-java-home \
&& mkdir -p /usr/share/man/man1 \
&& set -ex; \
\
apt list openjdk-21-jdk -a | grep openjdk-21-jdk ; \
apt-get install -y --no-install-recommends \
openjdk-21-jdk="$JAVA_DEBIAN_VERSION" \
; \
apt-get autoremove --purge --yes ; \
rm -rf /var/lib/apt/lists/*; \
# expire resolved DNS in 60 sec
echo 'networkaddress.cache.ttl=60' >> /etc/java-21-openjdk/security/java.security \
\
# verify that "docker-java-home" returns what we expect
[ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \
\
# basic smoke test
fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java; \
javac -version; \
java -version
164 changes: 164 additions & 0 deletions openjdk21/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<!--
Copyright © 2016-2020 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.thingsboard</groupId>
<version>1.7.0</version>
<artifactId>docker</artifactId>
</parent>
<artifactId>openjdk21</artifactId>
<packaging>pom</packaging>

<name>ThingsBoard Open JDK 21 Image</name>
<url>https://thingsboard.io</url>
<description>ThingsBoard Open JDK 21 Image</description>

<properties>
<main.dir>${basedir}/..</main.dir>
<docker.name>openjdk21</docker.name>
<docker.push-arm-amd-image.phase>pre-integration-test</docker.push-arm-amd-image.phase>
<docker.push-arm-amd-image-debian-codename.phase>pre-integration-test</docker.push-arm-amd-image-debian-codename.phase>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-docker-config</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>docker</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<executions>
<execution>
<id>build-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<skip>${dockerfile.skip}</skip>
<repository>${docker.repo}/${docker.name}</repository>
<verbose>true</verbose>
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
<contextDirectory>${project.build.directory}</contextDirectory>
<!-- This prevents checking the latest version on docker hub to address a manifest not found issue -->
<pullNewerImage>false</pullNewerImage>
</configuration>
</execution>
<execution>
<id>tag-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<skip>${dockerfile.skip}</skip>
<repository>${docker.repo}/${docker.name}</repository>
<tag>${project.version}</tag>
</configuration>
</execution>
<execution>
<id>tag-debian-codename-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<skip>${dockerfile.skip}</skip>
<repository>${docker.repo}/${docker.name}</repository>
<tag>${debian.codename}</tag>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>push-docker-image</id>
<activation>
<property>
<name>push-docker-image</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<executions>
<execution>
<id>push-latest-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>push</goal>
</goals>
<configuration>
<tag>latest</tag>
<repository>${docker.repo}/${docker.name}</repository>
</configuration>
</execution>
<execution>
<id>push-version-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>push</goal>
</goals>
<configuration>
<tag>${project.version}</tag>
<repository>${docker.repo}/${docker.name}</repository>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>jenkins</id>
<name>Jenkins Repository</name>
<url>http://repo.jenkins-ci.org/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<module>node</module>
<module>openjdk11</module>
<module>openjdk17</module>
<module>openjdk21</module>
<module>haproxy-certbot</module>
<module>website</module>
<module>toolbox</module>
Expand Down

0 comments on commit 10e0a23

Please sign in to comment.