Skip to content

Commit

Permalink
keep jdk21-preview for architectures unsupported by eclipse-temurin:2…
Browse files Browse the repository at this point in the history
…1 image
  • Loading branch information
lemeurherve committed Oct 17, 2023
1 parent 2cd50a0 commit 2eae836
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 2 deletions.
91 changes: 91 additions & 0 deletions debian/21/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
ARG DEBIAN_RELEASE=bookworm-20230904
FROM debian:"${DEBIAN_RELEASE}"-slim as jre-build
ARG JAVA_VERSION
ARG TARGETPLATFORM

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN set -x; apt-get update \
&& apt-get install --no-install-recommends -y \
ca-certificates \
jq \
wget \
&& BUILD_NUMBER=$(echo $JAVA_VERSION | cut -d'+' -f2) \
&& JAVA_MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'+' -f1) \
&& JAVA_VERSION_ENCODED=$(echo "$JAVA_VERSION" | jq "@uri" -jRr) \
&& CONVERTED_ARCH=$(arch | sed -e 's/x86_64/x64/' -e 's/armv7l/arm/') \
&& wget --quiet https://github.com/adoptium/temurin"${JAVA_MAJOR_VERSION}"-binaries/releases/download/jdk-"${JAVA_VERSION_ENCODED}"-ea-beta/OpenJDK"${JAVA_MAJOR_VERSION}"U-jdk_"${CONVERTED_ARCH}"_linux_hotspot_ea_"${JAVA_MAJOR_VERSION}"-0-"${BUILD_NUMBER}".tar.gz -O /tmp/jdk.tar.gz \
&& tar -xzf /tmp/jdk.tar.gz -C /opt/ \
&& rm -f /tmp/jdk.tar.gz

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

RUN if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \
jlink \
--add-modules ALL-MODULE-PATH \
--no-man-pages \
--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 \
cp -r "/opt/jdk-${JAVA_VERSION}" /javaruntime; \
fi

FROM debian:"${DEBIAN_RELEASE}" AS build

ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000

RUN groupadd -g "${gid}" "${group}" \
&& useradd -l -c "Jenkins user" -d /home/"${user}" -u "${uid}" -g "${gid}" -m "${user}"

ARG AGENT_WORKDIR=/home/"${user}"/agent
ENV TZ=Etc/UTC

## Always use the latest Debian packages: no need for versions
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get --yes --no-install-recommends install \
ca-certificates \
curl \
fontconfig \
git \
git-lfs \
less \
netbase \
openssh-client \
patch \
tzdata \
&& apt-get clean \
&& rm -rf /tmp/* /var/cache/* /usr/share/doc/* /usr/share/man/* /var/lib/apt/lists/*

ARG VERSION=3148.v532a_7e715ee3
ADD --chown="${user}":"${group}" "https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/${VERSION}/remoting-${VERSION}.jar" /usr/share/jenkins/agent.jar
RUN chmod 0644 /usr/share/jenkins/agent.jar \
&& 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}"
ENV AGENT_WORKDIR=${AGENT_WORKDIR}
RUN mkdir /home/${user}/.jenkins && mkdir -p "${AGENT_WORKDIR}"

VOLUME /home/"${user}"/.jenkins
VOLUME "${AGENT_WORKDIR}"
WORKDIR /home/"${user}"
ENV user=${user}
LABEL \
org.opencontainers.image.vendor="Jenkins project" \
org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.url="https://www.jenkins.io/" \
org.opencontainers.image.source="https://github.com/jenkinsci/docker-agent" \
org.opencontainers.image.licenses="MIT"
24 changes: 22 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ group "linux-arm32" {
targets = [
"debian_jdk11",
"debian_jdk17",
"debian_jdk21_preview"
]
}

group "linux-s390x" {
targets = [
"debian_jdk11",
"debian_jdk21_preview"
]
}

group "linux-ppc64le" {
targets = [
"debian_jdk11",
"debian_jdk17",
"debian_jdk21_preview"
]
}

Expand Down Expand Up @@ -209,7 +212,6 @@ target "debian_jdk17" {
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7", "linux/ppc64le"]
}


target "debian_jdk21" {
dockerfile = "debian/Dockerfile"
context = "."
Expand All @@ -225,5 +227,23 @@ target "debian_jdk21" {
"${REGISTRY}/${JENKINS_REPO}:latest-bookworm-jdk21",
"${REGISTRY}/${JENKINS_REPO}:latest-jdk21",
]
platforms = ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x", "linux/arm/v7"]
platforms = ["linux/amd64", "linux/arm64"]
}

target "debian_jdk21_preview" {
dockerfile = "debian/21/Dockerfile"
context = "."
args = {
JAVA_VERSION = JAVA21_VERSION
VERSION = REMOTING_VERSION
DEBIAN_RELEASE = DEBIAN_RELEASE
}
tags = [
equal(ON_TAG, "true") ? "${REGISTRY}/${JENKINS_REPO}:${REMOTING_VERSION}-${BUILD_NUMBER}-jdk21-preview" : "",
"${REGISTRY}/${JENKINS_REPO}:bookworm-jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:latest-bookworm-jdk21-preview",
"${REGISTRY}/${JENKINS_REPO}:latest-jdk21-preview",
]
platforms = ["linux/ppc64le", "linux/s390x", "linux/arm/v7"]
}

0 comments on commit 2eae836

Please sign in to comment.