Oleksii Molchanov | d23ab70 | 2021-04-05 13:05:32 +0300 | [diff] [blame] | 1 | FROM ubuntu:20.04 |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 2 | |
azvyagintsev | 6983fb9 | 2018-04-07 16:04:58 +0300 | [diff] [blame] | 3 | LABEL maintainer="dev@mirantis.com" |
Vladimir Khlyunev | 89dd173 | 2023-11-27 16:07:34 +0400 | [diff] [blame] | 4 | LABEL build_date="2023-11-27" |
azvyagintsev | 6983fb9 | 2018-04-07 16:04:58 +0300 | [diff] [blame] | 5 | |
| 6 | ENV DEBIAN_FRONTEND=noninteractive \ |
| 7 | DEBCONF_NONINTERACTIVE_SEEN=true \ |
| 8 | LANG=C.UTF-8 \ |
| 9 | LANGUAGE=$LANG |
| 10 | SHELL ["/bin/bash", "-xec"] |
| 11 | |
| 12 | # Base apt config |
| 13 | RUN 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 Khlyunev | 2223b66 | 2023-10-03 04:10:40 +0400 | [diff] [blame] | 18 | RUN apt-get update && apt-get -yy upgrade && apt-get install -y git curl gettext-base python3-virtualenv openjdk-11-jdk unzip wget |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 19 | |
| 20 | ENV JENKINS_HOME /var/jenkins_home |
jeichel | aebb8b2 | 2015-08-10 12:38:20 -0400 | [diff] [blame] | 21 | ENV JENKINS_SLAVE_AGENT_PORT 50000 |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 22 | |
Stig Bakken | 854a604 | 2016-03-14 17:04:27 +0100 | [diff] [blame] | 23 | ARG user=jenkins |
| 24 | ARG group=jenkins |
| 25 | ARG uid=1000 |
| 26 | ARG gid=1000 |
| 27 | |
Scott Newson | 39046ee | 2015-10-25 03:16:16 -0600 | [diff] [blame] | 28 | # Jenkins is run with user `jenkins`, uid = 1000 |
Filip Pytloun | 1e8af36 | 2017-03-16 13:58:44 +0100 | [diff] [blame] | 29 | # If you bind mount a volume from the host or a data container, |
Scott Newson | 39046ee | 2015-10-25 03:16:16 -0600 | [diff] [blame] | 30 | # ensure you use the same uid |
Stig Bakken | 854a604 | 2016-03-14 17:04:27 +0100 | [diff] [blame] | 31 | RUN groupadd -g ${gid} ${group} \ |
| 32 | && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user} |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 33 | |
Filip Pytloun | 1e8af36 | 2017-03-16 13:58:44 +0100 | [diff] [blame] | 34 | # Jenkins home directory is a volume, so configuration and build history |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 35 | # can be persisted and survive image upgrades |
| 36 | VOLUME /var/jenkins_home |
| 37 | |
Filip Pytloun | 1e8af36 | 2017-03-16 13:58:44 +0100 | [diff] [blame] | 38 | # `/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 Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 40 | # or config file with your custom jenkins Docker image. |
Filip Pytloun | e9e6f56 | 2016-08-31 16:30:33 +0200 | [diff] [blame] | 41 | RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d; chown ${uid}:${gid} /usr/share/jenkins/ref/init.groovy.d |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 42 | |
muicoder | bac415c | 2017-01-19 13:47:25 +0800 | [diff] [blame] | 43 | ENV TINI_VERSION 0.13.2 |
| 44 | ENV TINI_SHA afbf8de8a63ce8e4f18cb3f34dfdbbd354af68a1 |
Dionysis Grigoropoulos | b5b788c | 2015-08-12 03:07:53 +0300 | [diff] [blame] | 45 | |
Filip Pytloun | 1e8af36 | 2017-03-16 13:58:44 +0100 | [diff] [blame] | 46 | # Use tini as subreaper in Docker container to adopt zombie processes |
Thomas Orozco | c0d446e | 2016-12-05 21:11:25 +0100 | [diff] [blame] | 47 | RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini \ |
Carlos Sanchez | eecaeb2 | 2016-04-13 12:10:39 +0200 | [diff] [blame] | 48 | && echo "$TINI_SHA /bin/tini" | sha1sum -c - |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 49 | |
Jesse Glick | fc9e710 | 2015-04-28 09:37:28 -0400 | [diff] [blame] | 50 | COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 51 | |
Nicolas De loof | 31bc79c | 2016-08-04 14:25:22 +0200 | [diff] [blame] | 52 | # jenkins version being bundled in this docker image |
Yoanis Gil | 8fbb91f | 2016-03-15 21:45:19 -0400 | [diff] [blame] | 53 | ARG JENKINS_VERSION |
Vladimir Khlyunev | 5aabb37 | 2024-01-31 23:40:33 +0400 | [diff] [blame^] | 54 | ENV JENKINS_VERSION ${JENKINS_VERSION:-2.426.3} |
jpthiery | 3eb0f83 | 2015-11-12 13:47:35 +0100 | [diff] [blame] | 55 | |
Nicolas De loof | 31bc79c | 2016-08-04 14:25:22 +0200 | [diff] [blame] | 56 | # jenkins.war checksum, download will be validated using it |
Vladimir Khlyunev | 5aabb37 | 2024-01-31 23:40:33 +0400 | [diff] [blame^] | 57 | ARG JENKINS_SHA=ab439243a6a07e2e78fe7c3408c59609f7be3bf268947ac214657af96abad106 |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 58 | |
Nicolas De loof | 31bc79c | 2016-08-04 14:25:22 +0200 | [diff] [blame] | 59 | # Can be used to customize where jenkins.war get downloaded from |
Joe Ferguson | d187b53 | 2016-10-17 16:20:16 -0700 | [diff] [blame] | 60 | ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war |
Nicolas De loof | 31bc79c | 2016-08-04 14:25:22 +0200 | [diff] [blame] | 61 | |
Filip Pytloun | 1e8af36 | 2017-03-16 13:58:44 +0100 | [diff] [blame] | 62 | # could use ADD but this one does not check Last-Modified header neither does it allow to control checksum |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 63 | # see https://github.com/docker/docker/issues/8331 |
Nicolas De loof | 31bc79c | 2016-08-04 14:25:22 +0200 | [diff] [blame] | 64 | RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \ |
Jon Hermansen | 14d338e | 2017-03-04 07:26:56 -0800 | [diff] [blame] | 65 | && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha256sum -c - |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 66 | |
jamesHsiaoAcquia | aa66561 | 2016-04-21 10:55:00 -0400 | [diff] [blame] | 67 | ENV JENKINS_UC https://updates.jenkins.io |
Stig Bakken | 854a604 | 2016-03-14 17:04:27 +0100 | [diff] [blame] | 68 | RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 69 | |
| 70 | # for main web interface: |
| 71 | EXPOSE 8080 |
| 72 | |
| 73 | # will be used by attached slave agents: |
| 74 | EXPOSE 50000 |
| 75 | |
Carlos Sanchez | c8c95d1 | 2015-07-02 12:36:13 +0200 | [diff] [blame] | 76 | ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log |
Jesse Glick | 8cdfb1f | 2015-04-28 09:32:11 -0400 | [diff] [blame] | 77 | |
Ivan Berezovskiy | 3e05488 | 2018-11-30 15:54:26 +0400 | [diff] [blame] | 78 | COPY SimpleThemeDecorator.xml /opt/org.codefirst.SimpleThemeDecorator.xml |
| 79 | RUN chown ${user} /opt/org.codefirst.SimpleThemeDecorator.xml |
Jakub Pavlik | a067c49 | 2016-09-01 15:18:03 +0200 | [diff] [blame] | 80 | |
Stig Bakken | 854a604 | 2016-03-14 17:04:27 +0100 | [diff] [blame] | 81 | USER ${user} |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 82 | |
Vincent Latombe | c14af95 | 2016-07-18 10:20:12 +0200 | [diff] [blame] | 83 | COPY jenkins-support /usr/local/bin/jenkins-support |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 84 | COPY jenkins.sh /usr/local/bin/jenkins.sh |
Vladimir Khlyunev | cb02471 | 2022-02-28 19:50:43 +0400 | [diff] [blame] | 85 | COPY pre_startup_copy_plugins.sh /usr/local/bin/pre_startup_copy_plugins.sh |
Nicolas De Loof | d5aea67 | 2015-07-15 21:53:48 +0200 | [diff] [blame] | 86 | ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"] |
Nicolas De Loof | b75dc1a | 2015-03-17 11:24:05 +0100 | [diff] [blame] | 87 | |
Filip Pytloun | d17c92d | 2017-03-16 17:50:25 +0100 | [diff] [blame] | 88 | COPY theme /usr/share/jenkins/ref/userContent/theme |
Vladimir Khlyunev | cb02471 | 2022-02-28 19:50:43 +0400 | [diff] [blame] | 89 | COPY plugins_for_offline.txt /opt/ |
Filip Pytloun | 74ce0b0 | 2016-08-31 16:02:16 +0200 | [diff] [blame] | 90 | |
azvyagintsev | 6983fb9 | 2018-04-07 16:04:58 +0300 | [diff] [blame] | 91 | USER root |
Vladimir Khlyunev | cb02471 | 2022-02-28 19:50:43 +0400 | [diff] [blame] | 92 | RUN mkdir -p /opt/plugins_files_offline \ |
| 93 | && wget -P /opt/plugins_files_offline -i /opt/plugins_for_offline.txt \ |
| 94 | && pushd /opt/plugins_files_offline && for f in *.hpi; do mv -- "$f" "${f%.hpi}.jpi" ; done && popd \ |
| 95 | && chown -R ${user} /opt/plugins_files_offline |
| 96 | |
azvyagintsev | 6983fb9 | 2018-04-07 16:04:58 +0300 | [diff] [blame] | 97 | # Cleanup. |
Vladimir Khlyunev | cb02471 | 2022-02-28 19:50:43 +0400 | [diff] [blame] | 98 | RUN apt-get -y purge wget; apt-get -y autoremove; apt-get -y clean; |
| 99 | RUN rm -rf /root/.cache /var/lib/apt/lists/* rm -rf /tmp/* rm -rf /var/tmp/* |
azvyagintsev | 6983fb9 | 2018-04-07 16:04:58 +0300 | [diff] [blame] | 100 | # And switch it back |
| 101 | USER ${user} |