From 27ced391a6115fe4c38da7ad799e9ea6458c89ee Mon Sep 17 00:00:00 2001 From: Avinal Kumar Date: Wed, 9 Oct 2024 12:04:36 +0530 Subject: [PATCH] feat: add rhel9 dockerfile and update go-init - add Dockerfile based on rhel9 - update go-init version to 1.21 Signed-off-by: Avinal Kumar --- .ci-operator.yaml | 2 +- 2/Dockerfile.rhel9 | 97 +++++++++++++++++++++++++++++++++++ 2/go-init/Dockerfile | 6 +-- slave-base/Dockerfile.rhel9 | 58 +++++++++++++++++++++ slave-base/go-init/Dockerfile | 6 +-- 5 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 2/Dockerfile.rhel9 create mode 100644 slave-base/Dockerfile.rhel9 diff --git a/.ci-operator.yaml b/.ci-operator.yaml index 38718883b..a83f0f843 100644 --- a/.ci-operator.yaml +++ b/.ci-operator.yaml @@ -1,4 +1,4 @@ build_root_image: name: release namespace: openshift - tag: rhel-8-release-golang-1.21-openshift-4.16 + tag: rhel-9-release-golang-1.21-openshift-4.16 diff --git a/2/Dockerfile.rhel9 b/2/Dockerfile.rhel9 new file mode 100644 index 000000000..cedd3bd13 --- /dev/null +++ b/2/Dockerfile.rhel9 @@ -0,0 +1,97 @@ +############################################## +# Stage 1 : Build go-init +############################################## +FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.21-openshift-4.16 AS go-init-builder +ARG jenkins_version=latest +WORKDIR /go/src/github.com/openshift/jenkins +COPY . . +WORKDIR /go/src/github.com/openshift/jenkins/go-init +RUN GO111MODULE=off go build . && cp go-init /usr/bin + +############################################## +# Stage 2 : Build slave-base with go-init +############################################## +FROM registry.ci.openshift.org/ocp/4.16:cli +ARG jenkins_version=latest +COPY --from=go-init-builder /usr/bin/go-init /usr/bin/go-init + +# Jenkins image for OpenShift +# +# This image provides a Jenkins server, primarily intended for integration with +# OpenShift v3. +# +# Volumes: +# * /var/jenkins_home +# Environment: +# * $JENKINS_PASSWORD - Password for the Jenkins 'admin' user. + +ENV JENKINS_VERSION=2 \ + HOME=/var/lib/jenkins \ + JENKINS_HOME=/var/lib/jenkins \ + JENKINS_UC=https://updates.jenkins.io \ + OPENSHIFT_JENKINS_IMAGE_VERSION=4.16 \ + LANG=en_US.UTF-8 \ + LC_ALL=en_US.UTF-8 \ + INSTALL_JENKINS_VIA_RPMS=false +# openshift/ocp-build-data will change INSTALL_JENKINS_VIA_RPMS to true +# so that the osbs/brew builds will install via RPMs; when this runs +# in api.ci, it will employ the old centos style, download the plugins and +# redhat-stable core RPM for download + +LABEL io.k8s.description="Jenkins is a continuous integration server" \ + io.k8s.display-name="Jenkins 2" \ + io.openshift.tags="jenkins,jenkins2,ci" \ + io.openshift.expose-services="8080:http" \ + io.jenkins.version="${jenkins_version}" \ + io.openshift.s2i.scripts-url=image:///usr/libexec/s2i + +# Labels consumed by Red Hat build service +LABEL com.redhat.component="openshift-jenkins-2-container" \ + name="openshift4/jenkins-2-rhel9" \ + architecture="x86_64" \ + maintainer="openshift-dev-services+jenkins@redhat.com" + +# 8080 for main web interface, 50000 for slave agents +EXPOSE 8080 50000 + +# for backward compatibility with pre-3.6 installs leveraging a PV, where rpm installs went to /usr/lib64/jenkins, we are +# establishing a symbolic link for that guy as well, so that existing plugins in JENKINS_HOME/plugins pointing to +# /usr/lib64/jenkins will subsequently get redirected to /usr/lib/jenkins; it is confirmed that the 3.7 jenkins RHEL images +# do *NOT* have a /usr/lib64/jenkins path +RUN ln -s /usr/lib/jenkins /usr/lib64/jenkins && \ + 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" && \ + yum install -y $INSTALL_PKGS && \ + yum update -y && \ + rpm -V $INSTALL_PKGS && \ + yum clean all && \ + localedef -f UTF-8 -i en_US en_US.UTF-8 && \ + alternatives --set java $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \ + alternatives --set javac $(alternatives --display javac | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \ + 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 && \ + alternatives --set jar $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 4) + +COPY ./contrib/openshift /opt/openshift +COPY ./contrib/jenkins /usr/local/bin +ADD ./contrib/s2i /usr/libexec/s2i +ADD release.version /tmp/release.version + +RUN /usr/local/bin/install-jenkins-core-plugins.sh /opt/openshift/bundle-plugins.txt && \ + rm -rf /var/log/jenkins && \ + chmod -R 775 /etc/alternatives && \ + chmod -R 775 /var/lib/alternatives && \ + chmod -R 775 /usr/lib/jvm && \ + chmod 775 /usr/bin && \ + chmod 775 /usr/share/man/man1 && \ + mkdir -p /var/lib/origin && \ + chmod 775 /var/lib/origin && \ + chown -R 1001:0 /opt/openshift && \ + /usr/local/bin/fix-permissions /opt/openshift && \ + /usr/local/bin/fix-permissions /opt/openshift/configuration/init.groovy.d && \ + /usr/local/bin/fix-permissions /var/lib/jenkins && \ + /usr/local/bin/fix-permissions /var/log + + +VOLUME ["/var/lib/jenkins"] + +USER 1001 +ENTRYPOINT ["/usr/bin/go-init", "-main", "/usr/libexec/s2i/run"] diff --git a/2/go-init/Dockerfile b/2/go-init/Dockerfile index 21f528a49..49a4ad9dc 100644 --- a/2/go-init/Dockerfile +++ b/2/go-init/Dockerfile @@ -2,7 +2,7 @@ # Stage 1: Build go-init ########################################### -FROM openshift/origin-release:golang-1.12 AS builder +FROM openshift/origin-release:golang-1.21 AS builder COPY ./ /go/src/go-init RUN go install go-init @@ -10,5 +10,5 @@ RUN go install go-init # Stage 2: ubi-minimal image with go-init ########################################### -FROM registry.access.redhat.com/ubi7/ubi-minimal:latest -COPY --from=builder /go/bin/go-init /usr/bin/go-init \ No newline at end of file +FROM registry.access.redhat.com/ubi9/ubi-minimal:latest +COPY --from=builder /go/bin/go-init /usr/bin/go-init diff --git a/slave-base/Dockerfile.rhel9 b/slave-base/Dockerfile.rhel9 new file mode 100644 index 000000000..02a507df8 --- /dev/null +++ b/slave-base/Dockerfile.rhel9 @@ -0,0 +1,58 @@ +############################################## +# Stage 1 : Build go-init +############################################## +FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.21-openshift-4.16 AS go-init-builder +WORKDIR /go/src/github.com/openshift/jenkins +COPY . . +WORKDIR /go/src/github.com/openshift/jenkins/go-init +RUN GO111MODULE=off go build . && cp go-init /usr/bin + +############################################## +# Stage 2 : Build slave-base with go-init +############################################## +FROM registry.ci.openshift.org/ocp/4.16:cli +COPY --from=go-init-builder /usr/bin/go-init /usr/bin/go-init + +# Labels consumed by Red Hat build service +LABEL com.redhat.component="jenkins-slave-base-rhel9-container" \ + name="openshift4/jenkins-slave-base-rhel9" \ + architecture="x86_64" \ + io.k8s.display-name="Jenkins Slave Base" \ + io.k8s.description="The jenkins slave base image is intended to be built on top of, to add your own tools that your jenkins job needs. The slave base image includes all the jenkins logic to operate as a slave, so users just have to yum install any additional packages their specific jenkins job will need" \ + io.openshift.tags="openshift,jenkins,slave" \ + maintainer="openshift-dev-services+jenkins@redhat.com" + + +ENV HOME=/home/jenkins \ + LANG=en_US.UTF-8 \ + LC_ALL=en_US.UTF-8 + +USER root +# Install headless Java +RUN INSTALL_PKGS="glibc-langpack-en bc gettext git git-lfs java-21-openjdk-headless java-17-openjdk-headless lsof rsync tar unzip which zip bzip2 jq glibc-locale-source" && \ + yum install -y --setopt=tsflags=nodocs --disableplugin=subscription-manager $INSTALL_PKGS && \ + rpm -V $INSTALL_PKGS && \ + yum update -y && \ + yum clean all && \ + localedef -f UTF-8 -i en_US en_US.UTF-8 && \ + alternatives --set java $(alternatives --display java | grep 'family java-21-openjdk' | cut -d ' ' -f 1) && \ + mkdir -p /home/jenkins && \ + chown -R 1001:0 /home/jenkins && \ + chmod -R g+w /home/jenkins && \ + chmod -R 775 /etc/alternatives && \ + chmod -R 775 /var/lib/alternatives && \ + chmod -R 775 /usr/lib/jvm && \ + chmod 775 /usr/bin && \ + chmod 775 /usr/share/man/man1 && \ + mkdir -p /var/lib/origin && \ + chmod 775 /var/lib/origin + +# Copy the entrypoint +ADD contrib/bin/* /usr/local/bin/ + +# Run the Jenkins JNLP client +ENTRYPOINT ["/usr/bin/go-init", "-main", "/usr/local/bin/run-jnlp-client"] + +############################################## +# End +############################################## diff --git a/slave-base/go-init/Dockerfile b/slave-base/go-init/Dockerfile index 21f528a49..49a4ad9dc 100644 --- a/slave-base/go-init/Dockerfile +++ b/slave-base/go-init/Dockerfile @@ -2,7 +2,7 @@ # Stage 1: Build go-init ########################################### -FROM openshift/origin-release:golang-1.12 AS builder +FROM openshift/origin-release:golang-1.21 AS builder COPY ./ /go/src/go-init RUN go install go-init @@ -10,5 +10,5 @@ RUN go install go-init # Stage 2: ubi-minimal image with go-init ########################################### -FROM registry.access.redhat.com/ubi7/ubi-minimal:latest -COPY --from=builder /go/bin/go-init /usr/bin/go-init \ No newline at end of file +FROM registry.access.redhat.com/ubi9/ubi-minimal:latest +COPY --from=builder /go/bin/go-init /usr/bin/go-init