Skip to content

Commit

Permalink
Use consistent jlink args within Java versions (jenkinsci#1818)
Browse files Browse the repository at this point in the history
* Use ubi9:9.3-1552 (most recent release)

* Use consistent leading spaces on container label declaration

* Use consistent jlink args for Java 21

* Use consistent spaces on container label

* Use consistent jlink args for Java 17

The jlink command line arguments are specific to Java version but they
do not change within the major Java version.  No need for a conditional
at container build time when our Dockerfile definitions are already
specific to a Java major version.

* Use consistent jlink args for Java 11

The jlink command line arguments are specific to Java version but they
do not change within the major Java version.  No need for a conditional
at container build time when our Dockerfile definitions are already
specific to a Java major version.
  • Loading branch information
MarkEWaite committed Jan 27, 2024
1 parent eb4b463 commit 505ff98
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 58 deletions.
1 change: 1 addition & 0 deletions 11/alpine/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-alpine AS jre-build
# 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)
# Arguments to jlink are specific to Java 11 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--strip-debug \
Expand Down
4 changes: 4 additions & 0 deletions 11/debian/bookworm-slim/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ ARG JAVA_VERSION=11.0.22_7
ARG BOOKWORM_TAG=20240110
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-jammy as jre-build

# 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)
# Arguments to jlink are specific to Java 11 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--strip-debug \
Expand Down
6 changes: 6 additions & 0 deletions 11/debian/bookworm/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ ARG JAVA_VERSION=11.0.22_7
ARG BOOKWORM_TAG=20240110
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-jammy as jre-build

# 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)
# Arguments to jlink are specific to Java 11 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

Expand Down
8 changes: 2 additions & 6 deletions 17/alpine/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-alpine AS jre-build
# 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)
# Arguments to jlink are specific to Java 17 jlink
RUN if [ "$TARGETPLATFORM" != 'linux/arm/v7' ]; then \
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" ;; \
esac; \
jlink \
--add-modules ALL-MODULE-PATH \
"$strip_java_debug_flags" \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress=2 \
Expand Down
16 changes: 10 additions & 6 deletions 17/debian/bookworm-slim/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ ARG BOOKWORM_TAG=20240110
ARG JAVA_VERSION=17.0.10_7
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-jammy as jre-build

# 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)
# Arguments to jlink are specific to Java 17 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

FROM debian:bookworm-"${BOOKWORM_TAG}"-slim

Expand Down
30 changes: 18 additions & 12 deletions 17/debian/bookworm/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ ARG BOOKWORM_TAG=20240110
ARG JAVA_VERSION=17.0.10_7
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-jammy as jre-build

# 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)
# Arguments to jlink are specific to Java 17 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--compress=2 \
--output /javaruntime
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

FROM debian:bookworm-"${BOOKWORM_TAG}"

Expand Down Expand Up @@ -117,11 +123,11 @@ ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/jenkins.sh"]

# metadata labels
LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Docker image" \
org.opencontainers.image.description="The Jenkins Continuous Integration and Delivery server" \
org.opencontainers.image.version="${JENKINS_VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="https://github.com/jenkinsci/docker" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.licenses="MIT"
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Docker image" \
org.opencontainers.image.description="The Jenkins Continuous Integration and Delivery server" \
org.opencontainers.image.version="${JENKINS_VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="https://github.com/jenkinsci/docker" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.licenses="MIT"
11 changes: 7 additions & 4 deletions 17/rhel/ubi9/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-ubi9-minimal as jre-build
# 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)
# Arguments to jlink are specific to Java 17 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--compress=2 \
--output /javaruntime
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

FROM registry.access.redhat.com/ubi9/ubi:9.3-1552

Expand Down
10 changes: 3 additions & 7 deletions 21/alpine/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-alpine AS jre-build
# 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)
# Arguments to jlink are specific to Java 21 jlink
RUN if [ "$TARGETPLATFORM" != 'linux/arm/v7' ]; then \
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" ;; \
esac; \
jlink \
--add-modules ALL-MODULE-PATH \
"$strip_java_debug_flags" \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress=zip-6 \
--compress zip-6 \
--output /javaruntime; \
else \
cp -r /opt/java/openjdk /javaruntime; \
Expand Down
14 changes: 10 additions & 4 deletions 21/debian/bookworm-slim/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ ARG BOOKWORM_TAG=20240110
ARG JAVA_VERSION=21.0.2_13
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-jammy as jre-build

# 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)
# Arguments to jlink are specific to Java 21 jlink
RUN if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \
jlink \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--compress=zip-6 \
--output /javaruntime; \
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress zip-6 \
--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 \
Expand Down
30 changes: 18 additions & 12 deletions 21/debian/bookworm/hotspot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ ARG BOOKWORM_TAG=20240110
ARG JAVA_VERSION=21.0.2_13
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-jammy as jre-build

# 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)
# Arguments to jlink are specific to Java 21 jlink
RUN if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \
jlink \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--compress=zip-6 \
--output /javaruntime; \
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress zip-6 \
--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 \
Expand Down Expand Up @@ -123,11 +129,11 @@ ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/jenkins.sh"]

# metadata labels
LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Docker image" \
org.opencontainers.image.description="The Jenkins Continuous Integration and Delivery server" \
org.opencontainers.image.version="${JENKINS_VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="https://github.com/jenkinsci/docker" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.licenses="MIT"
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Docker image" \
org.opencontainers.image.description="The Jenkins Continuous Integration and Delivery server" \
org.opencontainers.image.version="${JENKINS_VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="https://github.com/jenkinsci/docker" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.licenses="MIT"
20 changes: 13 additions & 7 deletions 21/rhel/ubi9/hotspot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi9/ubi:9.3-1361 as jre-build
FROM registry.access.redhat.com/ubi9/ubi:9.3-1552 as jre-build
ARG JAVA_VERSION=21.0.2_13
ARG TARGETPLATFORM

Expand All @@ -22,13 +22,19 @@ RUN set -x; yum install -y jq wget \

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)
# Arguments to jlink are specific to Java 21 jlink
RUN jlink \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--compress=zip-6 \
--output /javaruntime

FROM registry.access.redhat.com/ubi9/ubi:9.3-1361
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress zip-6 \
--output /javaruntime

FROM registry.access.redhat.com/ubi9/ubi:9.3-1552

ENV LANG C.UTF-8

Expand Down

0 comments on commit 505ff98

Please sign in to comment.