blob: 74fab9fd4ab04d42904a9fd766901fdb6dbf9c81 [file] [log] [blame]
Carlos Sanchez64c7ca32016-08-15 13:36:55 +02001FROM openjdk:8-jdk
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +01002
Filip Pytlound903d9a2017-03-16 13:23:05 +01003RUN apt-get update && apt-get install -y git curl gettext-base && rm -rf /var/lib/apt/lists/*
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +01004
5ENV JENKINS_HOME /var/jenkins_home
jeichelaebb8b22015-08-10 12:38:20 -04006ENV JENKINS_SLAVE_AGENT_PORT 50000
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +01007
Stig Bakken854a6042016-03-14 17:04:27 +01008ARG user=jenkins
9ARG group=jenkins
10ARG uid=1000
11ARG gid=1000
12
Scott Newson39046ee2015-10-25 03:16:16 -060013# Jenkins is run with user `jenkins`, uid = 1000
Filip Pytloun1e8af362017-03-16 13:58:44 +010014# If you bind mount a volume from the host or a data container,
Scott Newson39046ee2015-10-25 03:16:16 -060015# ensure you use the same uid
Stig Bakken854a6042016-03-14 17:04:27 +010016RUN groupadd -g ${gid} ${group} \
17 && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user}
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010018
Filip Pytloun1e8af362017-03-16 13:58:44 +010019# Jenkins home directory is a volume, so configuration and build history
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010020# can be persisted and survive image upgrades
21VOLUME /var/jenkins_home
22
Filip Pytloun1e8af362017-03-16 13:58:44 +010023# `/usr/share/jenkins/ref/` contains all reference configuration we want
24# to set on a fresh new installation. Use it to bundle additional plugins
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010025# or config file with your custom jenkins Docker image.
Filip Pytloune9e6f562016-08-31 16:30:33 +020026RUN 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 +010027
muicoderbac415c2017-01-19 13:47:25 +080028ENV TINI_VERSION 0.13.2
29ENV TINI_SHA afbf8de8a63ce8e4f18cb3f34dfdbbd354af68a1
Dionysis Grigoropoulosb5b788c2015-08-12 03:07:53 +030030
Filip Pytloun1e8af362017-03-16 13:58:44 +010031# Use tini as subreaper in Docker container to adopt zombie processes
Thomas Orozcoc0d446e2016-12-05 21:11:25 +010032RUN 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 +020033 && echo "$TINI_SHA /bin/tini" | sha1sum -c -
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010034
Jesse Glickfc9e7102015-04-28 09:37:28 -040035COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010036
Nicolas De loof31bc79c2016-08-04 14:25:22 +020037# jenkins version being bundled in this docker image
Yoanis Gil8fbb91f2016-03-15 21:45:19 -040038ARG JENKINS_VERSION
Filip Pytlounb30e5fa2017-04-04 16:06:44 +020039ENV JENKINS_VERSION ${JENKINS_VERSION:-2.52}
jpthiery3eb0f832015-11-12 13:47:35 +010040
Nicolas De loof31bc79c2016-08-04 14:25:22 +020041# jenkins.war checksum, download will be validated using it
Filip Pytlounb30e5fa2017-04-04 16:06:44 +020042ARG JENKINS_SHA=7a78fc8b3f1eacd45891d052f7fa03471a60b9df52213b4ee948e05834cffc38
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010043
Nicolas De loof31bc79c2016-08-04 14:25:22 +020044# Can be used to customize where jenkins.war get downloaded from
Joe Fergusond187b532016-10-17 16:20:16 -070045ARG 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 +020046
Filip Pytloun1e8af362017-03-16 13:58:44 +010047# 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 +010048# see https://github.com/docker/docker/issues/8331
Nicolas De loof31bc79c2016-08-04 14:25:22 +020049RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war \
Jon Hermansen14d338e2017-03-04 07:26:56 -080050 && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha256sum -c -
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010051
jamesHsiaoAcquiaaa665612016-04-21 10:55:00 -040052ENV JENKINS_UC https://updates.jenkins.io
Stig Bakken854a6042016-03-14 17:04:27 +010053RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010054
55# for main web interface:
56EXPOSE 8080
57
58# will be used by attached slave agents:
59EXPOSE 50000
60
Carlos Sanchezc8c95d12015-07-02 12:36:13 +020061ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040062
Jakub Pavlika067c492016-09-01 15:18:03 +020063COPY SimpleThemeDecorator.xml /tmp/org.codefirst.SimpleThemeDecorator.xml
64RUN chown ${user} /tmp/org.codefirst.SimpleThemeDecorator.xml
65
Stig Bakken854a6042016-03-14 17:04:27 +010066USER ${user}
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010067
Vincent Latombec14af952016-07-18 10:20:12 +020068COPY jenkins-support /usr/local/bin/jenkins-support
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010069COPY jenkins.sh /usr/local/bin/jenkins.sh
Nicolas De Loofd5aea672015-07-15 21:53:48 +020070ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010071
Scott Newson39046ee2015-10-25 03:16:16 -060072# 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 +010073COPY plugins.sh /usr/local/bin/plugins.sh
Nicolas De Loofdfe81a32016-05-28 17:26:01 +020074COPY install-plugins.sh /usr/local/bin/install-plugins.sh
Filip Pytlound17c92d2017-03-16 17:50:25 +010075COPY theme /usr/share/jenkins/ref/userContent/theme
Filip Pytloun74ce0b02016-08-31 16:02:16 +020076
Filip Pytloun1e8af362017-03-16 13:58:44 +010077RUN JENKINS_UC_DOWNLOAD=http://archives.jenkins-ci.org /usr/local/bin/install-plugins.sh \
Filip Pytlound903d9a2017-03-16 13:23:05 +010078 ansicolor \
79 artifactory \
80 build-blocker-plugin \
81 build-monitor-plugin \
82 build-user-vars-plugin \
83 categorized-view \
84 description-setter \
85 discard-old-build \
86 docker-workflow \
Jakub Josef78b4c442017-04-27 18:46:33 +020087 email-ext \
Filip Pytlound903d9a2017-03-16 13:23:05 +010088 extended-choice-parameter \
Jakub Josefcf388012017-04-13 15:04:06 +020089 extensible-choice-parameter \
Filip Pytlound903d9a2017-03-16 13:23:05 +010090 gerrit-trigger \
Filip Pytlounb0994d92017-03-16 16:12:07 +010091 git \
Filip Pytlound903d9a2017-03-16 13:23:05 +010092 heavy-job \
Kirill Mashchenko3a755dc2017-10-16 16:19:03 +030093 jobConfigHistory \
Filip Pytlounb30e5fa2017-04-04 16:06:44 +020094 ldap \
Filip Pytloun4aa3ef82017-06-01 16:54:13 +020095 lockable-resources \
Filip Pytlound903d9a2017-03-16 13:23:05 +010096 matrix-auth \
97 monitoring \
98 permissive-script-security \
99 pipeline-utility-steps \
100 rebuild \
101 simple-theme-plugin \
102 slack \
103 test-stability \
104 timestamper \
105 workflow-cps \
106 workflow-remote-loader \
107 workflow-scm-step