diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 22887995..fcd8b6c9 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -24,22 +24,21 @@ ARG JAVA_VERSION=17.0.11_9 ARG ALPINE_TAG=3.19.1 FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-alpine AS jre-build -RUN if [ "$TARGETPLATFORM" != 'linux/arm/v7' ]; then \ - case "$(jlink --version 2>&1)" in \ +RUN case "$(jlink --version 2>&1)" in \ # jlink version 11 has less features than JDK17+ - "11."*) strip_java_debug_flags="--strip-debug" ;; \ - *) strip_java_debug_flags="--strip-java-debug-attributes" ;; \ + "11."*) set -- "--strip-debug" "--compress=2" ;; \ + "17."*) set -- "--strip-java-debug-attributes" "--compress=2" ;; \ + # the compression argument is different for JDK21 + "21."*) set -- "--strip-java-debug-attributes" "--compress=zip-6" ;; \ + *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ esac; \ jlink \ + "$1" \ + "$2" \ --add-modules ALL-MODULE-PATH \ - "$strip_java_debug_flags" \ --no-man-pages \ --no-header-files \ - --compress=2 \ - --output /javaruntime; \ - else \ - cp -r /opt/java/openjdk /javaruntime; \ - fi + --output /javaruntime FROM alpine:"${ALPINE_TAG}" AS build diff --git a/debian/Dockerfile b/debian/Dockerfile index de925ed4..a208c8f4 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -11,27 +11,21 @@ SHELL ["/bin/bash","-e", "-u", "-o", "pipefail", "-c"] # 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 if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \ - case "$(jlink --version 2>/dev/null)" in \ - # jlink version 11 has less features than JDK17+ - "11."*) strip_java_debug_flags=("--strip-debug") ;; \ - *) strip_java_debug_flags=("--strip-java-debug-attributes") ;; \ +RUN case "$(jlink --version 2>&1)" in \ + # jlink version 11 has less features than JDK17+ + "11."*) set -- "--strip-debug" "--compress=2" ;; \ + "17."*) set -- "--strip-java-debug-attributes" "--compress=2" ;; \ + # the compression argument is different for JDK21 + "21."*) set -- "--strip-java-debug-attributes" "--compress=zip-6" ;; \ + *) echo "ERROR: unmanaged jlink version pattern" && exit 1 ;; \ esac; \ - if test "${TARGETPLATFORM}" != 'linux/amd/64'; then \ - # posix_spawn (default for JDK12+) fails erratically with qemu on non x86 CPUs - https://github.com/openzipkin/docker-java/issues/34#issuecomment-721673618 - export JAVA_TOOL_OPTIONS='-Djdk.lang.Process.launchMechanism=vfork'; \ - fi; \ jlink \ - --add-modules ALL-MODULE-PATH \ - "${strip_java_debug_flags[@]}" \ - --no-man-pages \ - --no-header-files \ - --compress=2 \ - --output /javaruntime; \ - # It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment. - # Because jlink fails with the error "jmods: Value too large for defined data type" error. - else cp -r /opt/java/openjdk /javaruntime; \ - fi + "$1" \ + "$2" \ + --add-modules ALL-MODULE-PATH \ + --no-man-pages \ + --no-header-files \ + --output /javaruntime FROM debian:"${DEBIAN_RELEASE}" diff --git a/debian/preview/Dockerfile b/debian/preview/Dockerfile index c4c677a5..54830b56 100644 --- a/debian/preview/Dockerfile +++ b/debian/preview/Dockerfile @@ -20,30 +20,9 @@ RUN apt-get update \ ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}" -# 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 if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \ - case "$(jlink --version 2>/dev/null)" in \ - # jlink version 11 has less features than JDK17+ - "11."*) strip_java_debug_flags=("--strip-debug") ;; \ - *) strip_java_debug_flags=("--strip-java-debug-attributes") ;; \ - esac; \ - if test "${TARGETPLATFORM}" != 'linux/amd/64'; then \ - # posix_spawn (default for JDK12+) fails erratically with qemu on non x86 CPUs - https://github.com/openzipkin/docker-java/issues/34#issuecomment-721673618 - export JAVA_TOOL_OPTIONS='-Djdk.lang.Process.launchMechanism=vfork'; \ - fi; \ - jlink \ - --add-modules ALL-MODULE-PATH \ - "${strip_java_debug_flags[@]}" \ - --no-man-pages \ - --no-header-files \ - --compress=2 \ - --output /javaruntime; \ - # It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment. - # Because jlink fails with the error "jmods: Value too large for defined data type" error. - else cp -r "/opt/jdk-${JAVA_VERSION}" /javaruntime; \ - fi +# It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment. +# Because jlink fails with the error "jmods: Value too large for defined data type" error. +RUN cp -r "/opt/jdk-${JAVA_VERSION}" /javaruntime FROM debian:"${DEBIAN_RELEASE}"