blob: c1c721ca2e178a4dd48c72b257ed69ed7b3f09ff [file] [log] [blame]
Nicolas De loof2989f3b2015-09-01 08:23:00 +02001FROM java:8-jdk
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +01002
Carlos Sanchezd393aa62016-04-13 12:14:46 +02003RUN apt-get update && apt-get install -y git curl zip && 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
14# If you bind mount a volume from the host or a data container,
15# 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
Scott Newson39046ee2015-10-25 03:16:16 -060019# 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
23# `/usr/share/jenkins/ref/` contains all reference configuration we want
24# to set on a fresh new installation. Use it to bundle additional plugins
25# or config file with your custom jenkins Docker image.
26RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d
27
Dionysis Grigoropoulosb5b788c2015-08-12 03:07:53 +030028ENV TINI_SHA 066ad710107dc7ee05d3aa6e4974f01dc98f3888
29
Nicolas De Loofd5aea672015-07-15 21:53:48 +020030# Use tini as subreaper in Docker container to adopt zombie processes
Carlos Sanchez67f11892016-04-04 12:45:27 +020031RUN curl -fsSL https://github.com/krallin/tini/releases/download/v0.5.0/tini-static -o /bin/tini && chmod +x /bin/tini \
Carlos Sanchezeecaeb22016-04-13 12:10:39 +020032 && echo "$TINI_SHA /bin/tini" | sha1sum -c -
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010033
Jesse Glickfc9e7102015-04-28 09:37:28 -040034COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010035
Yoanis Gil8fbb91f2016-03-15 21:45:19 -040036ARG JENKINS_VERSION
Carlos Sanchez7a15c652016-05-12 12:01:30 +020037ENV JENKINS_VERSION ${JENKINS_VERSION:-2.3}
Yoanis Gil8fbb91f2016-03-15 21:45:19 -040038ARG JENKINS_SHA
Carlos Sanchez7a15c652016-05-12 12:01:30 +020039ENV JENKINS_SHA ${JENKINS_SHA:-d3097c9c81c7d5074d71a5059d85cf8977c1568e}
jpthiery3eb0f832015-11-12 13:47:35 +010040
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010041
42# could use ADD but this one does not check Last-Modified header
43# see https://github.com/docker/docker/issues/8331
Carlos Sanchez67f11892016-04-04 12:45:27 +020044RUN curl -fsSL http://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war -o /usr/share/jenkins/jenkins.war \
Carlos Sanchezeecaeb22016-04-13 12:10:39 +020045 && echo "$JENKINS_SHA /usr/share/jenkins/jenkins.war" | sha1sum -c -
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010046
jamesHsiaoAcquiaaa665612016-04-21 10:55:00 -040047ENV JENKINS_UC https://updates.jenkins.io
Stig Bakken854a6042016-03-14 17:04:27 +010048RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010049
50# for main web interface:
51EXPOSE 8080
52
53# will be used by attached slave agents:
54EXPOSE 50000
55
Carlos Sanchezc8c95d12015-07-02 12:36:13 +020056ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
Jesse Glick8cdfb1f2015-04-28 09:32:11 -040057
Stig Bakken854a6042016-03-14 17:04:27 +010058USER ${user}
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010059
60COPY jenkins.sh /usr/local/bin/jenkins.sh
Nicolas De Loofd5aea672015-07-15 21:53:48 +020061ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
Nicolas De Loofb75dc1a2015-03-17 11:24:05 +010062
Scott Newson39046ee2015-10-25 03:16:16 -060063# 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 +010064COPY plugins.sh /usr/local/bin/plugins.sh