Skip to content

Commit 9dd2494

Browse files
Merge pull request #1874 from openshift/konflux-onboard
JKNS-463: Containerfile for Konflux
2 parents d789754 + b2126a7 commit 9dd2494

File tree

2 files changed

+118
-15
lines changed

2 files changed

+118
-15
lines changed

2/.konflux/Containerfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
maintainer="[email protected]"
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"]

2/contrib/jenkins/install-jenkins-core-plugins.sh

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,37 @@ set -o pipefail
55
jenkins_version=$(cat /opt/openshift/jenkins-version.txt)
66
echo "Jenkins version: ${jenkins_version}"
77
if [[ "${INSTALL_JENKINS_VIA_RPMS}" == false ]]; then
8-
curl https://pkg.jenkins.io/redhat-stable/jenkins.repo -o /etc/yum.repos.d/jenkins.repo
9-
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins-ci.org.key
10-
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
11-
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
128
PLUGIN_LIST="$1"
139
echo "Plugin list wil be take from file: " $PLUGIN_LIST
1410
YUM_FLAGS=" "
1511
shift # Shift the script arguments. So $1 will be dropped in favor of $2
1612
if [ "$#" == "1" ]; then
1713
YUM_FLAGS="$1"
1814
fi
19-
YUM_CACHE=/var/cache/yum/x86_64/7Server/
20-
if [ -d $YUM_CACHE ]; then
21-
rm -fr /var/cache/yum/x86_64/7Server/*
22-
rm -fr /var/cache/yum/x86_64/7Server/ # Clean yum cache otherwise, it will fail if --disablerepos are specified
23-
fi
24-
# Since the recent LTS jenkins update we need to install the 'daemonize' package
25-
# which is only available in EPEL, so enable it here
26-
yum -y --setopt=tsflags=nodocs --disableplugin=subscription-manager install \
27-
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
28-
yum -y $YUM_FLAGS --setopt=tsflags=nodocs --disableplugin=subscription-manager install jenkins-${jenkins_version}
29-
yum $YUM_FLAGS clean all
15+
# Builds on Konflux will copy `jenkins.war` from a dependent container image to /usr/lib/jenkins
16+
# If the file is already present, we skip the upstream RPM installation
17+
if [[ -f "/usr/lib/jenkins/jenkins.war" ]]; then
18+
echo "jenkins.war already exists, skipping upstream RPM installation"
19+
else
20+
echo "Installing jenkins.war from upstream RPM"
21+
curl https://pkg.jenkins.io/redhat-stable/jenkins.repo -o /etc/yum.repos.d/jenkins.repo
22+
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins-ci.org.key
23+
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
24+
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
25+
26+
YUM_CACHE=/var/cache/yum/x86_64/7Server/
27+
if [ -d $YUM_CACHE ]; then
28+
rm -fr /var/cache/yum/x86_64/7Server/*
29+
rm -fr /var/cache/yum/x86_64/7Server/ # Clean yum cache otherwise, it will fail if --disablerepos are specified
30+
fi
31+
# Since the recent LTS jenkins update we need to install the 'daemonize' package
32+
# which is only available in EPEL, so enable it here
33+
yum -y --setopt=tsflags=nodocs --disableplugin=subscription-manager install \
34+
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
35+
yum -y $YUM_FLAGS --setopt=tsflags=nodocs --disableplugin=subscription-manager install jenkins-${jenkins_version}
36+
yum $YUM_FLAGS clean all
37+
fi
38+
3039
/usr/local/bin/install-plugins.sh $PLUGIN_LIST
3140
else
3241
yum install -y --disableplugin=subscription-manager jenkins-2.* jenkins-2-plugins

0 commit comments

Comments
 (0)