blob: 3cda148146672239b4dbe06bbab2487fe68e577b [file] [log] [blame]
Oleksii Molchanovd23ab702021-04-05 13:05:32 +03001FROM ubuntu:20.04
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +01002
azvyagintsev6983fb92018-04-07 16:04:58 +03003LABEL maintainer="dev@mirantis.com"
Vladimir Khlyunevcb024712022-02-28 19:50:43 +04004LABEL build_date="2022-04-12"
azvyagintsev6983fb92018-04-07 16:04:58 +03005
6ENV DEBIAN_FRONTEND=noninteractive \
7 DEBCONF_NONINTERACTIVE_SEEN=true \
8 LANG=C.UTF-8 \
9 LANGUAGE=$LANG
10SHELL ["/bin/bash", "-xec"]
11
12# Base apt config
13RUN cd /etc/apt/ \
14 && echo 'Acquire::Languages "none";' > apt.conf.d/docker-no-languages \
15 && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > apt.conf.d/docker-gzip-indexes \
16 && echo 'APT::Get::Install-Recommends "false"; APT::Get::Install-Suggests "false";' > apt.conf.d/docker-recommends
17
Vladimir Khlyunevcb024712022-02-28 19:50:43 +040018RUN apt-get update && apt-get -yy upgrade && apt-get install -y git curl gettext-base python3-virtualenv openjdk-8-jdk unzip wget
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010019
20ENV JENKINS_HOME /var/jenkins_home
jeichelaebb8b22015-08-10 12:38:20 -040021ENV JENKINS_SLAVE_AGENT_PORT 50000
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010022
Stig Bakken854a6042016-03-14 17:04:27 +010023ARG user=jenkins
24ARG group=jenkins
25ARG uid=1000
26ARG gid=1000
27
Scott Newson39046ee2015-10-25 03:16:16 -060028# Jenkins is run with user `jenkins`, uid = 1000
Filip Pytloun1e8af362017-03-16 13:58:44 +010029# If you bind mount a volume from the host or a data container,
Scott Newson39046ee2015-10-25 03:16:16 -060030# ensure you use the same uid
Stig Bakken854a6042016-03-14 17:04:27 +010031RUN groupadd -g ${gid} ${group} \
32 && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user}
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010033
Filip Pytloun1e8af362017-03-16 13:58:44 +010034# Jenkins home directory is a volume, so configuration and build history
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010035# can be persisted and survive image upgrades
36VOLUME /var/jenkins_home
37
Filip Pytloun1e8af362017-03-16 13:58:44 +010038# `/usr/share/jenkins/ref/` contains all reference configuration we want
39# to set on a fresh new installation. Use it to bundle additional plugins
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010040# or config file with your custom jenkins Docker image.
Filip Pytloune9e6f562016-08-31 16:30:33 +020041RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d; chown ${uid}:${gid} /usr/share/jenkins/ref/init.groovy.d
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010042
muicoderbac415c2017-01-19 13:47:25 +080043ENV TINI_VERSION 0.13.2
44ENV TINI_SHA afbf8de8a63ce8e4f18cb3f34dfdbbd354af68a1
Dionysis Grigoropoulosb5b788c2015-08-12 03:07:53 +030045
Filip Pytloun1e8af362017-03-16 13:58:44 +010046# Use tini as subreaper in Docker container to adopt zombie processes
Thomas Orozcoc0d446e2016-12-05 21:11:25 +010047RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini \
Carlos Sanchezeecaeb22016-04-13 12:10:39 +020048 && echo "$TINI_SHA /bin/tini" | sha1sum -c -
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010049
Jesse Glickfc9e7102015-04-28 09:37:28 -040050COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010051
Nicolas De loof31bc79c2016-08-04 14:25:22 +020052# jenkins version being bundled in this docker image
Yoanis Gil8fbb91f2016-03-15 21:45:19 -040053ARG JENKINS_VERSION
Vladimir Khlyuneveb6540f2021-06-09 18:11:48 +000054ENV JENKINS_VERSION ${JENKINS_VERSION:-2.263.4}
jpthiery3eb0f832015-11-12 13:47:35 +010055
Nicolas De loof31bc79c2016-08-04 14:25:22 +020056# jenkins.war checksum, download will be validated using it
Vladimir Khlyuneveb6540f2021-06-09 18:11:48 +000057ARG JENKINS_SHA=1d4a7409784236a84478b76f3f2139939c0d7a3b4b2e53b1fcef400c14903ab6
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010058
Nicolas De loof31bc79c2016-08-04 14:25:22 +020059# Can be used to customize where jenkins.war get downloaded from
Joe Fergusond187b532016-10-17 16:20:16 -070060ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war
Nicolas De loof31bc79c2016-08-04 14:25:22 +020061
Filip Pytloun1e8af362017-03-16 13:58:44 +010062# could use ADD but this one does not check Last-Modified header neither does it allow to control checksum
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010063# see https://github.com/docker/docker/issues/8331
Nicolas De loof31bc79c2016-08-04 14:25:22 +020064RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
Jon Hermansen14d338e2017-03-04 07:26:56 -080065 && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha256sum -c -
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010066
jamesHsiaoAcquiaaa665612016-04-21 10:55:00 -040067ENV JENKINS_UC https://updates.jenkins.io
Stig Bakken854a6042016-03-14 17:04:27 +010068RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010069
70# for main web interface:
71EXPOSE 8080
72
73# will be used by attached slave agents:
74EXPOSE 50000
75
Carlos Sanchezc8c95d12015-07-02 12:36:13 +020076ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040077
Ivan Berezovskiy3e054882018-11-30 15:54:26 +040078COPY SimpleThemeDecorator.xml /opt/org.codefirst.SimpleThemeDecorator.xml
79RUN chown ${user} /opt/org.codefirst.SimpleThemeDecorator.xml
Jakub Pavlika067c492016-09-01 15:18:03 +020080
Stig Bakken854a6042016-03-14 17:04:27 +010081USER ${user}
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010082
Vincent Latombec14af952016-07-18 10:20:12 +020083COPY jenkins-support /usr/local/bin/jenkins-support
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010084COPY jenkins.sh /usr/local/bin/jenkins.sh
Vladimir Khlyunevcb024712022-02-28 19:50:43 +040085COPY pre_startup_copy_plugins.sh /usr/local/bin/pre_startup_copy_plugins.sh
Nicolas De Loofd5aea672015-07-15 21:53:48 +020086ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010087
Scott Newson39046ee2015-10-25 03:16:16 -060088# from a derived Dockerfile, can use `RUN plugins.sh active.txt` to setup /usr/share/jenkins/ref/plugins from a support bundle
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010089COPY plugins.sh /usr/local/bin/plugins.sh
Nicolas De Loofdfe81a32016-05-28 17:26:01 +020090COPY install-plugins.sh /usr/local/bin/install-plugins.sh
Denis Egorenko6ddff322018-11-08 16:44:02 +040091COPY jenkins-plugins-deps /usr/share/jenkins/ref/jenkins-plugins-deps
Filip Pytlound17c92d2017-03-16 17:50:25 +010092COPY theme /usr/share/jenkins/ref/userContent/theme
Vladimir Khlyunevcb024712022-02-28 19:50:43 +040093COPY plugins_for_offline.txt /opt/
Filip Pytloun74ce0b02016-08-31 16:02:16 +020094
azvyagintsev6983fb92018-04-07 16:04:58 +030095USER root
Vladimir Khlyunevcb024712022-02-28 19:50:43 +040096RUN mkdir -p /opt/plugins_files_offline \
97 && wget -P /opt/plugins_files_offline -i /opt/plugins_for_offline.txt \
98 && pushd /opt/plugins_files_offline && for f in *.hpi; do mv -- "$f" "${f%.hpi}.jpi" ; done && popd \
99 && chown -R ${user} /opt/plugins_files_offline
100
azvyagintsev6983fb92018-04-07 16:04:58 +0300101# Cleanup.
Vladimir Khlyunevcb024712022-02-28 19:50:43 +0400102RUN apt-get -y purge wget; apt-get -y autoremove; apt-get -y clean;
103RUN rm -rf /root/.cache /var/lib/apt/lists/* rm -rf /tmp/* rm -rf /var/tmp/*
azvyagintsev6983fb92018-04-07 16:04:58 +0300104# And switch it back
105USER ${user}