Skip to content

Commit

Permalink
restore jlink in favor of jenkinsci#799
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherve committed May 6, 2024
1 parent 1ef59a8 commit e72a514
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 42 deletions.
19 changes: 10 additions & 9 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@ RUN apk add --no-cache \

ENV PATH="/opt/jdk-${JAVA_VERSION}/bin:${PATH}"

RUN case "$(jlink --version 2>&1)" in \
RUN if [ "$TARGETPLATFORM" != 'linux/arm/v7' ]; then \
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 ;; \
"11."*) strip_java_debug_flags="--strip-debug" ;; \
*) strip_java_debug_flags="--strip-java-debug-attributes" ;; \
esac; \
jlink \
"$1" \
"$2" \
--add-modules ALL-MODULE-PATH \
"$strip_java_debug_flags" \
--no-man-pages \
--no-header-files \
--output /javaruntime
--compress=2 \
--output /javaruntime; \
else \
cp -r "/opt/jdk-${JAVA_VERSION}" /javaruntime; \
fi

## Agent image target
FROM alpine:"${ALPINE_TAG}" AS agent
Expand Down
22 changes: 7 additions & 15 deletions archlinux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,13 @@ 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 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; \
jlink \
"$1" \
"$2" \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--no-header-files \
--output /javaruntime
RUN jlink \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

FROM archlinux:base-20240101.0.204074

Expand Down
34 changes: 16 additions & 18 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,22 @@ 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 [[ "${TARGETPLATFORM}" != "linux/arm/v7" ]]; then \
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; \
jlink \
"$1" \
"$2" \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--no-header-files \
--output /javaruntime; \
else \
cp -r "/opt/jdk-${JAVA_VERSION}" /javaruntime; \
RUN if test "${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[@]}" \
--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

## Agent image target
Expand Down

0 comments on commit e72a514

Please sign in to comment.