|
| 1 | +ARG BOOKWORM_TAG=20230904 |
| 2 | +FROM debian:bookworm-"${BOOKWORM_TAG}"-slim as jre-build |
| 3 | +ARG JAVA_VERSION=21+35 |
| 4 | +ARG TARGETPLATFORM |
| 5 | + |
| 6 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 7 | + |
| 8 | +RUN set -x; apt-get update \ |
| 9 | + && apt-get install --no-install-recommends -y \ |
| 10 | + ca-certificates \ |
| 11 | + jq \ |
| 12 | + wget \ |
| 13 | + && BUILD_NUMBER=$(echo $JAVA_VERSION | cut -d'+' -f2) \ |
| 14 | + && JAVA_VERSION_ENCODED=$(echo "$JAVA_VERSION" | jq "@uri" -jRr) \ |
| 15 | + && CONVERTED_ARCH=$(arch | sed -e 's/x86_64/x64/' -e 's/armv7l/arm/') \ |
| 16 | + && wget --quiet https://github.com/adoptium/temurin21-binaries/releases/download/jdk-"${JAVA_VERSION_ENCODED}"-ea-beta/OpenJDK21U-jdk_"${CONVERTED_ARCH}"_linux_hotspot_ea_21-0-"${BUILD_NUMBER}".tar.gz -O /tmp/jdk.tar.gz \ |
| 17 | + && tar -xzf /tmp/jdk.tar.gz -C /opt/ \ |
| 18 | + && rm -f /tmp/jdk.tar.gz |
| 19 | + |
| 20 | +ENV PATH=/opt/jdk-${JAVA_VERSION}/bin:$PATH |
| 21 | + |
| 22 | +RUN if test "${TARGETPLATFORM}" != 'linux/arm/v7'; then \ |
| 23 | + jlink \ |
| 24 | + --add-modules ALL-MODULE-PATH \ |
| 25 | + --no-man-pages \ |
| 26 | + --compress=zip-6 \ |
| 27 | + --output /javaruntime; \ |
| 28 | + # It is acceptable to have a larger image in arm/v7 (arm 32 bits) environment. |
| 29 | + # Because jlink fails with the error "jmods: Value too large for defined data type" error. |
| 30 | + else \ |
| 31 | + cp -r "/opt/jdk-${JAVA_VERSION}" /javaruntime; \ |
| 32 | + fi |
| 33 | + |
| 34 | +FROM debian:bookworm-"${BOOKWORM_TAG}"-slim |
| 35 | + |
| 36 | +RUN apt-get update \ |
| 37 | + && apt-get install -y --no-install-recommends \ |
| 38 | + ca-certificates \ |
| 39 | + curl \ |
| 40 | + git \ |
| 41 | + gnupg \ |
| 42 | + gpg \ |
| 43 | + libfontconfig1 \ |
| 44 | + libfreetype6 \ |
| 45 | + procps \ |
| 46 | + ssh-client \ |
| 47 | + tini \ |
| 48 | + unzip \ |
| 49 | + tzdata \ |
| 50 | + && rm -rf /var/lib/apt/lists/* |
| 51 | + |
| 52 | +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh -o /tmp/script.deb.sh \ |
| 53 | + && bash /tmp/script.deb.sh \ |
| 54 | + && rm -f /tmp/script.deb.sh \ |
| 55 | + && apt-get install -y --no-install-recommends \ |
| 56 | + git-lfs \ |
| 57 | + && rm -rf /var/lib/apt/lists/* \ |
| 58 | + && git lfs install |
| 59 | + |
| 60 | +ENV LANG C.UTF-8 |
| 61 | + |
| 62 | +ARG TARGETARCH |
| 63 | +ARG COMMIT_SHA |
| 64 | + |
| 65 | +ARG user=jenkins |
| 66 | +ARG group=jenkins |
| 67 | +ARG uid=1000 |
| 68 | +ARG gid=1000 |
| 69 | +ARG http_port=8080 |
| 70 | +ARG agent_port=50000 |
| 71 | +ARG JENKINS_HOME=/var/jenkins_home |
| 72 | +ARG REF=/usr/share/jenkins/ref |
| 73 | + |
| 74 | +ENV JENKINS_HOME $JENKINS_HOME |
| 75 | +ENV JENKINS_SLAVE_AGENT_PORT ${agent_port} |
| 76 | +ENV REF $REF |
| 77 | + |
| 78 | +# Jenkins is run with user `jenkins`, uid = 1000 |
| 79 | +# If you bind mount a volume from the host or a data container, |
| 80 | +# ensure you use the same uid |
| 81 | +RUN mkdir -p $JENKINS_HOME \ |
| 82 | + && chown ${uid}:${gid} $JENKINS_HOME \ |
| 83 | + && groupadd -g ${gid} ${group} \ |
| 84 | + && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -l -m -s /bin/bash ${user} |
| 85 | + |
| 86 | +# Jenkins home directory is a volume, so configuration and build history |
| 87 | +# can be persisted and survive image upgrades |
| 88 | +VOLUME $JENKINS_HOME |
| 89 | + |
| 90 | +# $REF (defaults to `/usr/share/jenkins/ref/`) contains all reference configuration we want |
| 91 | +# to set on a fresh new installation. Use it to bundle additional plugins |
| 92 | +# or config file with your custom jenkins Docker image. |
| 93 | +RUN mkdir -p ${REF}/init.groovy.d |
| 94 | + |
| 95 | +# jenkins version being bundled in this docker image |
| 96 | +ARG JENKINS_VERSION |
| 97 | +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.427} |
| 98 | + |
| 99 | +# jenkins.war checksum, download will be validated using it |
| 100 | +ARG JENKINS_SHA=0fc5c7b9956221ed7deac1ce7c2ac3f86d0059fac6ceabfec11718550fb701d2 |
| 101 | + |
| 102 | +# Can be used to customize where jenkins.war get downloaded from |
| 103 | +ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war |
| 104 | + |
| 105 | +# could use ADD but this one does not check Last-Modified header neither does it allow to control checksum |
| 106 | +# see https://github.com/docker/docker/issues/8331 |
| 107 | +RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \ |
| 108 | + && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" >/tmp/jenkins_sha \ |
| 109 | + && sha256sum -c --strict /tmp/jenkins_sha \ |
| 110 | + && rm -f /tmp/jenkins_sha |
| 111 | + |
| 112 | +ENV JENKINS_UC https://updates.jenkins.io |
| 113 | +ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental |
| 114 | +ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals |
| 115 | +RUN chown -R ${user} "$JENKINS_HOME" "$REF" |
| 116 | + |
| 117 | +ARG PLUGIN_CLI_VERSION=2.12.13 |
| 118 | +ARG PLUGIN_CLI_URL=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/${PLUGIN_CLI_VERSION}/jenkins-plugin-manager-${PLUGIN_CLI_VERSION}.jar |
| 119 | +RUN curl -fsSL ${PLUGIN_CLI_URL} -o /opt/jenkins-plugin-manager.jar |
| 120 | + |
| 121 | +# for main web interface: |
| 122 | +EXPOSE ${http_port} |
| 123 | + |
| 124 | +# will be used by attached agents: |
| 125 | +EXPOSE ${agent_port} |
| 126 | + |
| 127 | +ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log |
| 128 | + |
| 129 | +ENV JAVA_HOME=/opt/java/openjdk |
| 130 | +ENV PATH "${JAVA_HOME}/bin:${PATH}" |
| 131 | +COPY --from=jre-build /javaruntime $JAVA_HOME |
| 132 | + |
| 133 | +USER ${user} |
| 134 | + |
| 135 | +COPY jenkins-support /usr/local/bin/jenkins-support |
| 136 | +COPY jenkins.sh /usr/local/bin/jenkins.sh |
| 137 | +COPY jenkins-plugin-cli.sh /bin/jenkins-plugin-cli |
| 138 | + |
| 139 | +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/jenkins.sh"] |
| 140 | + |
| 141 | +# metadata labels |
| 142 | +LABEL \ |
| 143 | + org.opencontainers.image.vendor="Jenkins project" \ |
| 144 | + org.opencontainers.image.title="Official Jenkins Docker image" \ |
| 145 | + org.opencontainers.image.description="The Jenkins Continuous Integration and Delivery server" \ |
| 146 | + org.opencontainers.image.version="${JENKINS_VERSION}" \ |
| 147 | + org.opencontainers.image.url="https://www.jenkins.io/" \ |
| 148 | + org.opencontainers.image.source="https://github.com/jenkinsci/docker" \ |
| 149 | + org.opencontainers.image.revision="${COMMIT_SHA}" \ |
| 150 | + org.opencontainers.image.licenses="MIT" |
0 commit comments