From ee0d22745863a4030cb4fdd9c2dc36d1cef8a133 Mon Sep 17 00:00:00 2001 From: Chandana Giri Date: Sun, 26 May 2024 19:12:48 +0530 Subject: [PATCH 1/2] Added Java 17 support --- rootfs-app.dockerfile | 2 +- rootfs-builder.dockerfile | 2 +- scripts/compilation.py | 30 ++++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/rootfs-app.dockerfile b/rootfs-app.dockerfile index 4a73910..815de7e 100644 --- a/rootfs-app.dockerfile +++ b/rootfs-app.dockerfile @@ -12,7 +12,7 @@ ENV LC_ALL C.UTF-8 # install dependencies & remove package lists RUN microdnf update -y && \ microdnf module enable nginx:1.20 -y && \ - microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless tzdata-java fontconfig binutils && \ + microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless java-17-openjdk-headless tzdata-java fontconfig binutils && \ microdnf clean all && rm -rf /var/cache/yum # Set nginx permissions diff --git a/rootfs-builder.dockerfile b/rootfs-builder.dockerfile index c8b2ae7..6ed4f87 100644 --- a/rootfs-builder.dockerfile +++ b/rootfs-builder.dockerfile @@ -33,7 +33,7 @@ RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch. microdnf clean all && rm -rf /var/cache/yum # Install RHEL alternatives to CF Buildpack dependencies -RUN microdnf install -y java-11-openjdk-headless java-11-openjdk-devel tzdata-java mono-core-5.20.1.34 libgdiplus0 libicu && \ +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 && \ microdnf clean all && rm -rf /var/cache/yum # Set nginx permissions diff --git a/scripts/compilation.py b/scripts/compilation.py index b3eae17..83ecc5f 100755 --- a/scripts/compilation.py +++ b/scripts/compilation.py @@ -56,7 +56,7 @@ def replace_cf_dependencies(): symlink.linkname = destination tar.addfile(symlink) - # Only JDK 11 is supported by Docker Buildpack + # JDK 11 support by Docker Buildpack jdk_dependency = get_dependency("java.11-jdk", "/opt/mendix/buildpack") logging.debug("Creating symlink for jdk {0}".format(jdk_dependency['artifact'])) jdk_cache_artifact = f"/tmp/buildcache/bust/{jdk_dependency['artifact']}" @@ -69,7 +69,20 @@ def replace_cf_dependencies(): symlink.linkname = f"{jdk_destination}/{jdk_dir}" tar.addfile(symlink) - # Only JRE 11 is supported by Docker Buildpack + # JDK 17 support by Docker Buildpack + jdk_dependency = get_dependency("java.17-jdk", "/opt/mendix/buildpack") + logging.debug("Creating symlink for jdk {0}".format(jdk_dependency['artifact'])) + jdk_cache_artifact = f"/tmp/buildcache/bust/{jdk_dependency['artifact']}" + jdk_destination = '/etc/alternatives/java_sdk_17' + with tarfile.open(jdk_cache_artifact, "w:gz") as tar: + # Symlinks to use jdk from host OS + for jdk_dir in os.listdir(jdk_destination): + symlink = tarfile.TarInfo(f"jdk/{jdk_dir}") + symlink.type = tarfile.SYMTYPE + symlink.linkname = f"{jdk_destination}/{jdk_dir}" + tar.addfile(symlink) + + # JRE 11 support by Docker Buildpack jre_dependency = get_dependency("java.11-jre", "/opt/mendix/buildpack") logging.debug("Creating symlink for jre {0}".format(jre_dependency['artifact'])) jre_cache_artifact = f"/tmp/buildcache/bust/{jre_dependency['artifact']}" @@ -82,6 +95,19 @@ def replace_cf_dependencies(): symlink.linkname = f"{jre_destination}/{jre_dir}" tar.addfile(symlink) + # JRE 17 support by Docker Buildpack + jre_dependency = get_dependency("java.17-jre", "/opt/mendix/buildpack") + logging.debug("Creating symlink for jre {0}".format(jre_dependency['artifact'])) + jre_cache_artifact = f"/tmp/buildcache/bust/{jre_dependency['artifact']}" + jre_destination = '/etc/alternatives/jre_17' + with tarfile.open(jre_cache_artifact, "w:gz") as tar: + # Symlinks to use jre from host OS + for jre_dir in os.listdir(jre_destination): + symlink = tarfile.TarInfo(f"jre/{jre_dir}") + symlink.type = tarfile.SYMTYPE + symlink.linkname = f"{jre_destination}/{jre_dir}" + tar.addfile(symlink) + def call_buildpack_compilation(): logging.debug("Executing call_buildpack_compilation...") return runpy.run_module("buildpack.stage", run_name="__main__") From 1b7c219a2633b5a1f84f2f96845f4750ce0544bc Mon Sep 17 00:00:00 2001 From: Chandana Giri Date: Mon, 27 May 2024 12:58:20 +0530 Subject: [PATCH 2/2] Added Java support for both 11 and 21 versions --- rootfs-app.dockerfile | 2 +- rootfs-builder.dockerfile | 2 +- scripts/compilation.py | 46 +++++++++++++-------------------------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/rootfs-app.dockerfile b/rootfs-app.dockerfile index 815de7e..bd9d2a4 100644 --- a/rootfs-app.dockerfile +++ b/rootfs-app.dockerfile @@ -12,7 +12,7 @@ ENV LC_ALL C.UTF-8 # install dependencies & remove package lists RUN microdnf update -y && \ microdnf module enable nginx:1.20 -y && \ - microdnf install -y glibc-langpack-en python311 openssl nginx nginx-mod-stream java-11-openjdk-headless java-17-openjdk-headless tzdata-java fontconfig binutils && \ + 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 && \ microdnf clean all && rm -rf /var/cache/yum # Set nginx permissions diff --git a/rootfs-builder.dockerfile b/rootfs-builder.dockerfile index 6ed4f87..65ecc8d 100644 --- a/rootfs-builder.dockerfile +++ b/rootfs-builder.dockerfile @@ -33,7 +33,7 @@ RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch. microdnf clean all && rm -rf /var/cache/yum # Install RHEL alternatives to CF Buildpack dependencies -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 && \ +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 && \ microdnf clean all && rm -rf /var/cache/yum # Set nginx permissions diff --git a/scripts/compilation.py b/scripts/compilation.py index 83ecc5f..29d2912 100755 --- a/scripts/compilation.py +++ b/scripts/compilation.py @@ -55,12 +55,19 @@ def replace_cf_dependencies(): symlink.type = tarfile.SYMTYPE symlink.linkname = destination tar.addfile(symlink) - - # JDK 11 support by Docker Buildpack - jdk_dependency = get_dependency("java.11-jdk", "/opt/mendix/buildpack") + get_jdk_dependency("java.11-jdk","java_sdk_11") + get_jdk_dependency("java.17-jdk","java_sdk_17") + get_jdk_dependency("java.21-jdk","java_sdk_21") + get_jre_dependency("java.11-jre","jre_11") + get_jre_dependency("java.17-jre","jre_17") + get_jre_dependency("java.21-jre","jre_21") + +# JDK 11, 17, 21 support by Docker Buildpack +def get_jdk_dependency(jdk_version, jdk_destination_version): + jdk_dependency = get_dependency(jdk_version, "/opt/mendix/buildpack") logging.debug("Creating symlink for jdk {0}".format(jdk_dependency['artifact'])) jdk_cache_artifact = f"/tmp/buildcache/bust/{jdk_dependency['artifact']}" - jdk_destination = '/etc/alternatives/java_sdk_11' + jdk_destination = '/etc/alternatives/'+jdk_destination_version with tarfile.open(jdk_cache_artifact, "w:gz") as tar: # Symlinks to use jdk from host OS for jdk_dir in os.listdir(jdk_destination): @@ -69,24 +76,13 @@ def replace_cf_dependencies(): symlink.linkname = f"{jdk_destination}/{jdk_dir}" tar.addfile(symlink) - # JDK 17 support by Docker Buildpack - jdk_dependency = get_dependency("java.17-jdk", "/opt/mendix/buildpack") - logging.debug("Creating symlink for jdk {0}".format(jdk_dependency['artifact'])) - jdk_cache_artifact = f"/tmp/buildcache/bust/{jdk_dependency['artifact']}" - jdk_destination = '/etc/alternatives/java_sdk_17' - with tarfile.open(jdk_cache_artifact, "w:gz") as tar: - # Symlinks to use jdk from host OS - for jdk_dir in os.listdir(jdk_destination): - symlink = tarfile.TarInfo(f"jdk/{jdk_dir}") - symlink.type = tarfile.SYMTYPE - symlink.linkname = f"{jdk_destination}/{jdk_dir}" - tar.addfile(symlink) - # JRE 11 support by Docker Buildpack - jre_dependency = get_dependency("java.11-jre", "/opt/mendix/buildpack") +# JRE 11, 17, 21 support by Docker Buildpack +def get_jre_dependency(jre_version, jre_destination_version): + jre_dependency = get_dependency(jre_version, "/opt/mendix/buildpack") logging.debug("Creating symlink for jre {0}".format(jre_dependency['artifact'])) jre_cache_artifact = f"/tmp/buildcache/bust/{jre_dependency['artifact']}" - jre_destination = '/etc/alternatives/jre_11' + jre_destination = '/etc/alternatives/'+jre_destination_version with tarfile.open(jre_cache_artifact, "w:gz") as tar: # Symlinks to use jre from host OS for jre_dir in os.listdir(jre_destination): @@ -95,18 +91,6 @@ def replace_cf_dependencies(): symlink.linkname = f"{jre_destination}/{jre_dir}" tar.addfile(symlink) - # JRE 17 support by Docker Buildpack - jre_dependency = get_dependency("java.17-jre", "/opt/mendix/buildpack") - logging.debug("Creating symlink for jre {0}".format(jre_dependency['artifact'])) - jre_cache_artifact = f"/tmp/buildcache/bust/{jre_dependency['artifact']}" - jre_destination = '/etc/alternatives/jre_17' - with tarfile.open(jre_cache_artifact, "w:gz") as tar: - # Symlinks to use jre from host OS - for jre_dir in os.listdir(jre_destination): - symlink = tarfile.TarInfo(f"jre/{jre_dir}") - symlink.type = tarfile.SYMTYPE - symlink.linkname = f"{jre_destination}/{jre_dir}" - tar.addfile(symlink) def call_buildpack_compilation(): logging.debug("Executing call_buildpack_compilation...")