|
| 1 | +############################################## |
| 2 | +# Stage 1 : Reference binary dependencies |
| 3 | +############################################## |
| 4 | +FROM quay.io/redhat-user-workloads/ocp-tools-jenkins-tenant/adambkaplan-go-init-4-17@sha256:42be4b464de1194585f5ba14b292f2ecaf309a123c732a3870f1afce50db4e5c AS go-init |
| 5 | + |
| 6 | +FROM quay.io/redhat-user-workloads/ocp-tools-jenkins-tenant/jenkinsci-jenkins-4-17@sha256:95a2d0577cf954702a23c4ee8aef3ec9ad9ae1eed7a98a8f17cf063e3a95a9ae AS jenkins-war |
| 7 | +############################################## |
| 8 | +# Stage 2 : Build Jenkins controller with Konflux-built binaries. |
| 9 | +############################################## |
| 10 | +FROM registry.redhat.io/openshift4/ose-cli-rhel9:v4.17 |
| 11 | +ARG jenkins_version=latest |
| 12 | +COPY --from=go-init /usr/bin/go-init /usr/bin/go-init |
| 13 | +COPY --from=jenkins-war /deployments/jenkins.war /usr/lib/jenkins/jenkins.war |
| 14 | + |
| 15 | +# Jenkins image for OpenShift |
| 16 | +# |
| 17 | +# This image provides a Jenkins server, primarily intended for integration with |
| 18 | +# OpenShift v4. |
| 19 | +# |
| 20 | +# Volumes: |
| 21 | +# * /var/jenkins_home |
| 22 | +# Environment: |
| 23 | +# * $JENKINS_PASSWORD - Password for the Jenkins 'admin' user. |
| 24 | + |
| 25 | +ENV JENKINS_VERSION=2 \ |
| 26 | + HOME=/var/lib/jenkins \ |
| 27 | + JENKINS_HOME=/var/lib/jenkins \ |
| 28 | + JENKINS_UC=https://updates.jenkins.io \ |
| 29 | + OPENSHIFT_JENKINS_IMAGE_VERSION=4.16 \ |
| 30 | + LANG=en_US.UTF-8 \ |
| 31 | + LC_ALL=en_US.UTF-8 \ |
| 32 | + # Setting INSTALL_JENKINS_VIA_RPS=true is used for CPaaS-driven builds, where we package |
| 33 | + # `jenkins.war` and the plugins into RPMs. On Konflux, we can source binaries from containers |
| 34 | + # or OCI artifacts. |
| 35 | + INSTALL_JENKINS_VIA_RPMS=false |
| 36 | + |
| 37 | +LABEL io.k8s.description="Jenkins is a continuous integration server" \ |
| 38 | + io.k8s.display-name="Jenkins 2" \ |
| 39 | + io.openshift.tags="jenkins,jenkins2,ci" \ |
| 40 | + io.openshift.expose-services="8080:http" \ |
| 41 | + io.jenkins.version="${jenkins_version}" \ |
| 42 | + io.openshift.s2i.scripts-url=image:///usr/libexec/s2i |
| 43 | + |
| 44 | +# Labels consumed by Red Hat build service |
| 45 | +LABEL com.redhat.component="openshift-jenkins-2-container" \ |
| 46 | + name="openshift4/jenkins-2-rhel9" \ |
| 47 | + architecture="x86_64" \ |
| 48 | + |
| 49 | + |
| 50 | +# 8080 for main web interface, 50000 for slave agents |
| 51 | +EXPOSE 8080 50000 |
| 52 | + |
| 53 | +# for backward compatibility with pre-3.6 installs leveraging a PV, where rpm installs went to /usr/lib64/jenkins, we are |
| 54 | +# establishing a symbolic link for that guy as well, so that existing plugins in JENKINS_HOME/plugins pointing to |
| 55 | +# /usr/lib64/jenkins will subsequently get redirected to /usr/lib/jenkins; it is confirmed that the 3.7 jenkins RHEL images |
| 56 | +# do *NOT* have a /usr/lib64/jenkins path |
| 57 | +RUN ln -s /usr/lib/jenkins /usr/lib64/jenkins && \ |
| 58 | + INSTALL_PKGS="dejavu-sans-fonts wget rsync gettext git git-lfs tar zip unzip openssl bzip2 java-21-openjdk java-21-openjdk-devel java-17-openjdk java-17-openjdk-devel jq glibc-locale-source xmlstarlet glibc-langpack-en" && \ |
| 59 | + yum install -y $INSTALL_PKGS && \ |
| 60 | + yum update -y && \ |
| 61 | + rpm -V $INSTALL_PKGS && \ |
| 62 | + yum clean all && \ |
| 63 | + localedef -f UTF-8 -i en_US en_US.UTF-8 && \ |
| 64 | + alternatives --set java $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \ |
| 65 | + alternatives --set javac $(alternatives --display javac | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \ |
| 66 | + alternatives --family $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 4) --install /usr/bin/jar jar $(alternatives --display java | grep 'family java-21-openjdk' | cut -d' ' -f1 | sed 's,/[^/]*$,/jar,') 1 && \ |
| 67 | + alternatives --set jar $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 4) |
| 68 | + |
| 69 | +COPY ./contrib/openshift /opt/openshift |
| 70 | +COPY ./contrib/jenkins /usr/local/bin |
| 71 | +ADD ./contrib/s2i /usr/libexec/s2i |
| 72 | +ADD release.version /tmp/release.version |
| 73 | + |
| 74 | +RUN mkdir -p /var/lib/jenkins && \ |
| 75 | + /usr/local/bin/install-jenkins-core-plugins.sh /opt/openshift/bundle-plugins.txt && \ |
| 76 | + rm -rf /var/log/jenkins && \ |
| 77 | + chmod -R 775 /etc/alternatives && \ |
| 78 | + chmod -R 775 /var/lib/alternatives && \ |
| 79 | + chmod -R 775 /usr/lib/jvm && \ |
| 80 | + chmod 775 /usr/bin && \ |
| 81 | + chmod 775 /usr/share/man/man1 && \ |
| 82 | + mkdir -p /var/lib/origin && \ |
| 83 | + chmod 775 /var/lib/origin && \ |
| 84 | + chown -R 1001:0 /opt/openshift && \ |
| 85 | + /usr/local/bin/fix-permissions /opt/openshift && \ |
| 86 | + /usr/local/bin/fix-permissions /opt/openshift/configuration/init.groovy.d && \ |
| 87 | + /usr/local/bin/fix-permissions /var/lib/jenkins && \ |
| 88 | + /usr/local/bin/fix-permissions /var/log |
| 89 | + |
| 90 | + |
| 91 | +VOLUME ["/var/lib/jenkins"] |
| 92 | + |
| 93 | +USER 1001 |
| 94 | +ENTRYPOINT ["/usr/bin/go-init", "-main", "/usr/libexec/s2i/run"] |
0 commit comments