Skip to content

Commit 1b7c219

Browse files
Added Java support for both 11 and 21 versions
1 parent ee0d227 commit 1b7c219

3 files changed

Lines changed: 17 additions & 33 deletions

File tree

rootfs-app.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ENV LC_ALL C.UTF-8
1212
# install dependencies & remove package lists
1313
RUN microdnf update -y && \
1414
microdnf module enable nginx:1.20 -y && \
15-
microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless java-17-openjdk-headless tzdata-java fontconfig binutils && \
15+
microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless java-17-openjdk-headless java-21-openjdk-headless tzdata-java fontconfig binutils && \
1616
microdnf clean all && rm -rf /var/cache/yum
1717

1818
# Set nginx permissions

rootfs-builder.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.
3333
microdnf clean all && rm -rf /var/cache/yum
3434

3535
# Install RHEL alternatives to CF Buildpack dependencies
36-
RUN microdnf install -y java-11-openjdk-headless java-11-openjdk-devel java-17-openjdk-headless java-17-openjdk-devel tzdata-java mono-core-5.20.1.34 libgdiplus0 libicu && \
36+
RUN microdnf install -y java-11-openjdk-headless java-11-openjdk-devel java-17-openjdk-headless java-17-openjdk-devel java-21-openjdk-headless java-21-openjdk-devel tzdata-java mono-core-5.20.1.34 libgdiplus0 libicu && \
3737
microdnf clean all && rm -rf /var/cache/yum
3838

3939
# Set nginx permissions

scripts/compilation.py

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,19 @@ def replace_cf_dependencies():
5555
symlink.type = tarfile.SYMTYPE
5656
symlink.linkname = destination
5757
tar.addfile(symlink)
58-
59-
# JDK 11 support by Docker Buildpack
60-
jdk_dependency = get_dependency("java.11-jdk", "/opt/mendix/buildpack")
58+
get_jdk_dependency("java.11-jdk","java_sdk_11")
59+
get_jdk_dependency("java.17-jdk","java_sdk_17")
60+
get_jdk_dependency("java.21-jdk","java_sdk_21")
61+
get_jre_dependency("java.11-jre","jre_11")
62+
get_jre_dependency("java.17-jre","jre_17")
63+
get_jre_dependency("java.21-jre","jre_21")
64+
65+
# JDK 11, 17, 21 support by Docker Buildpack
66+
def get_jdk_dependency(jdk_version, jdk_destination_version):
67+
jdk_dependency = get_dependency(jdk_version, "/opt/mendix/buildpack")
6168
logging.debug("Creating symlink for jdk {0}".format(jdk_dependency['artifact']))
6269
jdk_cache_artifact = f"/tmp/buildcache/bust/{jdk_dependency['artifact']}"
63-
jdk_destination = '/etc/alternatives/java_sdk_11'
70+
jdk_destination = '/etc/alternatives/'+jdk_destination_version
6471
with tarfile.open(jdk_cache_artifact, "w:gz") as tar:
6572
# Symlinks to use jdk from host OS
6673
for jdk_dir in os.listdir(jdk_destination):
@@ -69,24 +76,13 @@ def replace_cf_dependencies():
6976
symlink.linkname = f"{jdk_destination}/{jdk_dir}"
7077
tar.addfile(symlink)
7178

72-
# JDK 17 support by Docker Buildpack
73-
jdk_dependency = get_dependency("java.17-jdk", "/opt/mendix/buildpack")
74-
logging.debug("Creating symlink for jdk {0}".format(jdk_dependency['artifact']))
75-
jdk_cache_artifact = f"/tmp/buildcache/bust/{jdk_dependency['artifact']}"
76-
jdk_destination = '/etc/alternatives/java_sdk_17'
77-
with tarfile.open(jdk_cache_artifact, "w:gz") as tar:
78-
# Symlinks to use jdk from host OS
79-
for jdk_dir in os.listdir(jdk_destination):
80-
symlink = tarfile.TarInfo(f"jdk/{jdk_dir}")
81-
symlink.type = tarfile.SYMTYPE
82-
symlink.linkname = f"{jdk_destination}/{jdk_dir}"
83-
tar.addfile(symlink)
8479

85-
# JRE 11 support by Docker Buildpack
86-
jre_dependency = get_dependency("java.11-jre", "/opt/mendix/buildpack")
80+
# JRE 11, 17, 21 support by Docker Buildpack
81+
def get_jre_dependency(jre_version, jre_destination_version):
82+
jre_dependency = get_dependency(jre_version, "/opt/mendix/buildpack")
8783
logging.debug("Creating symlink for jre {0}".format(jre_dependency['artifact']))
8884
jre_cache_artifact = f"/tmp/buildcache/bust/{jre_dependency['artifact']}"
89-
jre_destination = '/etc/alternatives/jre_11'
85+
jre_destination = '/etc/alternatives/'+jre_destination_version
9086
with tarfile.open(jre_cache_artifact, "w:gz") as tar:
9187
# Symlinks to use jre from host OS
9288
for jre_dir in os.listdir(jre_destination):
@@ -95,18 +91,6 @@ def replace_cf_dependencies():
9591
symlink.linkname = f"{jre_destination}/{jre_dir}"
9692
tar.addfile(symlink)
9793

98-
# JRE 17 support by Docker Buildpack
99-
jre_dependency = get_dependency("java.17-jre", "/opt/mendix/buildpack")
100-
logging.debug("Creating symlink for jre {0}".format(jre_dependency['artifact']))
101-
jre_cache_artifact = f"/tmp/buildcache/bust/{jre_dependency['artifact']}"
102-
jre_destination = '/etc/alternatives/jre_17'
103-
with tarfile.open(jre_cache_artifact, "w:gz") as tar:
104-
# Symlinks to use jre from host OS
105-
for jre_dir in os.listdir(jre_destination):
106-
symlink = tarfile.TarInfo(f"jre/{jre_dir}")
107-
symlink.type = tarfile.SYMTYPE
108-
symlink.linkname = f"{jre_destination}/{jre_dir}"
109-
tar.addfile(symlink)
11094

11195
def call_buildpack_compilation():
11296
logging.debug("Executing call_buildpack_compilation...")

0 commit comments

Comments
 (0)