Skip to content

Commit

Permalink
fix(debian_jdk17) revert jenkinsci#310 and use to detect if arm/v7 or…
Browse files Browse the repository at this point in the history
… not

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
  • Loading branch information
dduportal committed Nov 16, 2022
1 parent 70c7dba commit 0217d06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 41 deletions.
29 changes: 12 additions & 17 deletions 17/bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

# To avoid "jmods: Value too large for defined data type" error,
# Check docker bake target debian_jdk17_arm32
# Cannot get jlink to properly work, in the v7 environment.
# The jmods error above gets generated each time.
# Better to have a larger image than incorrect java binaries in 32bit arm.
ARG JAVA_VERSION=17.0.5_8
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-focal AS arm32-jre-build
RUN cp -r /opt/java/openjdk /javaruntime

ARG JAVA_VERSION=17.0.5_8
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-focal AS jre-build

# This Build ARG is populated by Docker
# Ref. https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG TARGETPLATFORM

# 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 jlink \
RUN if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \
jlink \
--add-modules ALL-MODULE-PATH \
--strip-java-debug-attributes \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime
--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

FROM debian:bullseye-20221024 AS build

Expand Down Expand Up @@ -73,6 +73,7 @@ RUN ln -sf /usr/share/jenkins/agent.jar /usr/share/jenkins/slave.jar
ENV LANG C.UTF-8

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=jre-build /javaruntime "$JAVA_HOME"
ENV PATH "${JAVA_HOME}/bin:${PATH}"

USER "${user}"
Expand All @@ -91,9 +92,3 @@ LABEL \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"

FROM build AS default
COPY --from=jre-build /javaruntime "$JAVA_HOME"

FROM build AS arm32
COPY --from=arm32-jre-build /javaruntime "$JAVA_HOME"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2015-2020 Jenkins project contributors
Copyright (c) 2015-2022 Jenkins project contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 2 additions & 23 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ group "linux" {
"archlinux_jdk11",
"debian_jdk11",
"debian_jdk17",
"debian_jdk17_arm32"
]
}

Expand All @@ -19,7 +18,7 @@ group "linux-arm64" {
group "linux-arm32" {
targets = [
"debian_jdk11",
"debian_jdk17_arm32"
"debian_jdk17"
]
}

Expand Down Expand Up @@ -145,33 +144,13 @@ target "debian_jdk17" {
context = "."
args = {
VERSION = REMOTING_VERSION,

}
target = "default"
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk17": "",
"${REGISTRY}/${JENKINS_REPO}:bullseye-jdk17",
"${REGISTRY}/${JENKINS_REPO}:jdk17",
"${REGISTRY}/${JENKINS_REPO}:latest-bullseye-jdk17",
"${REGISTRY}/${JENKINS_REPO}:latest-jdk17",
]
platforms = ["linux/amd64", "linux/arm64"]
}

target "debian_jdk17_arm32" {
dockerfile = "17/bullseye/Dockerfile"
context = "."
args = {
VERSION = REMOTING_VERSION,

}
target = "arm32"
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk17": "",
"${REGISTRY}/${JENKINS_REPO}:bullseye-jdk17",
"${REGISTRY}/${JENKINS_REPO}:jdk17",
"${REGISTRY}/${JENKINS_REPO}:latest-bullseye-jdk17",
"${REGISTRY}/${JENKINS_REPO}:latest-jdk17",
]
platforms = ["linux/arm/v7"]
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"]
}

0 comments on commit 0217d06

Please sign in to comment.