From fcb7185a97154d406dfabafe3ce37980f8dfad9c Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 17 Sep 2025 14:31:29 +0200 Subject: [PATCH 1/2] feat: add JDK25 preview support for Linux images - Add JDK25 version variable (25+9-ea-beta) to docker-bake.hcl - Update jlink configuration for JDK25 with specific modules - Create separate Windows JDK build matrix excluding JDK25 - Support JDK25 on Alpine and Debian Linux platforms only --- alpine/Dockerfile | 23 +++++++++++------------ debian/Dockerfile | 23 +++++++++++------------ docker-bake.hcl | 22 ++++++++++++++++------ 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/alpine/Dockerfile b/alpine/Dockerfile index d7bc0df6..6651d997 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -44,18 +44,17 @@ RUN apk add --no-cache \ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}" RUN case "$(jlink --version 2>&1)" in \ - "17."*) set -- "--compress=2" ;; \ - # the compression argument is different for JDK21 - "21."*) set -- "--compress=zip-6" ;; \ - *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ - esac; \ - jlink \ - --strip-java-debug-attributes \ - "$1" \ - --add-modules ALL-MODULE-PATH \ - --no-man-pages \ - --no-header-files \ - --output /javaruntime + "17."*) set -- "--compress=2" --add-modules ALL-MODULE-PATH ;; \ + "21."*) set -- "--compress=zip-6" --add-modules ALL-MODULE-PATH ;; \ + "25"*) set -- "--compress=zip-6" --add-modules java.base,java.logging,java.xml,java.management,java.net.http,jdk.crypto.ec ;; \ + *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ + esac; \ + jlink \ + --strip-java-debug-attributes \ + "$@" \ + --no-man-pages \ + --no-header-files \ + --output /javaruntime FROM alpine:"${ALPINE_TAG}" AS build diff --git a/debian/Dockerfile b/debian/Dockerfile index 99e1ff14..0d88e3f1 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -46,18 +46,17 @@ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}" # for now we include the full module path to maintain compatibility # while still saving space (approx 200mb from the full distribution) RUN case "$(jlink --version 2>&1)" in \ - "17."*) set -- "--compress=2" ;; \ - # the compression argument is different for JDK21 - "21."*) set -- "--compress=zip-6" ;; \ - *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ - esac; \ - jlink \ - --strip-java-debug-attributes \ - "$1" \ - --add-modules ALL-MODULE-PATH \ - --no-man-pages \ - --no-header-files \ - --output /javaruntime + "17."*) set -- "--compress=2" --add-modules ALL-MODULE-PATH ;; \ + "21."*) set -- "--compress=zip-6" --add-modules ALL-MODULE-PATH ;; \ + "25"*) set -- "--compress=zip-6" --add-modules java.base,java.logging,java.xml,java.management,java.net.http,jdk.crypto.ec ;; \ + *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ + esac; \ + jlink \ + --strip-java-debug-attributes \ + "$@" \ + --no-man-pages \ + --no-header-files \ + --output /javaruntime FROM debian:"${DEBIAN_RELEASE}" diff --git a/docker-bake.hcl b/docker-bake.hcl index 485ff844..ad8d59e2 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -32,6 +32,10 @@ group "linux-ppc64le" { } variable "jdks_to_build" { + default = [17, 21, 25] +} + +variable "jdks_to_build_windows" { default = [17, 21] } @@ -71,6 +75,10 @@ variable "JAVA21_VERSION" { default = "21.0.8_9" } +variable "JAVA25_VERSION" { + default = "25+9-ea-beta" +} + variable "DEBIAN_RELEASE" { default = "trixie-20250908" } @@ -92,16 +100,18 @@ function "javaversion" { params = [jdk] result = (equal(17, jdk) ? "${JAVA17_VERSION}" - : "${JAVA21_VERSION}") + : equal(21, jdk) + ? "${JAVA21_VERSION}" + : "${JAVA25_VERSION}") } ## Specific functions # Return an array of Alpine platforms to use depending on the jdk passed as parameter function "alpine_platforms" { params = [jdk] - result = (equal(21, jdk) - ? ["linux/amd64", "linux/arm64"] - : ["linux/amd64"]) + result = (equal(17, jdk) + ? ["linux/amd64"] + : ["linux/amd64", "linux/arm64"]) } # Return an array of Debian platforms to use depending on the jdk passed as parameter @@ -191,7 +201,7 @@ target "debian" { target "nanoserver" { matrix = { - jdk = jdks_to_build + jdk = jdks_to_build_windows windows_version = windowsversions("nanoserver") } name = "nanoserver-${windows_version}_jdk${jdk}" @@ -216,7 +226,7 @@ target "nanoserver" { target "windowsservercore" { matrix = { - jdk = jdks_to_build + jdk = jdks_to_build_windows windows_version = windowsversions("windowsservercore") } name = "windowsservercore-${windows_version}_jdk${jdk}" From 4000a02552ad0f2ec9861a18fd19fe3a4aaab9c3 Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Wed, 17 Sep 2025 14:38:32 +0200 Subject: [PATCH 2/2] feat: enhance JDK 25 support by allowing custom JLINK_MODULES for image optimization --- alpine/Dockerfile | 6 +++++- debian/Dockerfile | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 6651d997..e6c052c5 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -43,10 +43,14 @@ RUN apk add --no-cache \ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}" +ARG JLINK_MODULES + RUN case "$(jlink --version 2>&1)" in \ "17."*) set -- "--compress=2" --add-modules ALL-MODULE-PATH ;; \ "21."*) set -- "--compress=zip-6" --add-modules ALL-MODULE-PATH ;; \ - "25"*) set -- "--compress=zip-6" --add-modules java.base,java.logging,java.xml,java.management,java.net.http,jdk.crypto.ec ;; \ + # JDK 25 switches to a minimal module set for smaller images. Override with JLINK_MODULES to restore broader compatibility if needed. + "25"*) mod_list="${JLINK_MODULES:-java.base,java.logging,java.xml,java.management,java.net.http,jdk.crypto.ec}"; \ + set -- "--compress=zip-6" --add-modules "$mod_list" ;; \ *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ esac; \ jlink \ diff --git a/debian/Dockerfile b/debian/Dockerfile index 0d88e3f1..a441c9d3 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -42,13 +42,17 @@ RUN set -x; apt-get update \ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}" +ARG JLINK_MODULES + # Generate smaller java runtime without unneeded files # for now we include the full module path to maintain compatibility # while still saving space (approx 200mb from the full distribution) RUN case "$(jlink --version 2>&1)" in \ "17."*) set -- "--compress=2" --add-modules ALL-MODULE-PATH ;; \ "21."*) set -- "--compress=zip-6" --add-modules ALL-MODULE-PATH ;; \ - "25"*) set -- "--compress=zip-6" --add-modules java.base,java.logging,java.xml,java.management,java.net.http,jdk.crypto.ec ;; \ + # JDK 25 switches to a minimal module set for smaller images. Override with JLINK_MODULES to restore broader compatibility if needed. + "25"*) mod_list="${JLINK_MODULES:-java.base,java.logging,java.xml,java.management,java.net.http,jdk.crypto.ec}"; \ + set -- "--compress=zip-6" --add-modules "$mod_list" ;; \ *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ esac; \ jlink \