|
| 1 | +FROM ubuntu:17.04 |
| 2 | +ENV DEBIAN_FRONTEND noninteractive |
| 3 | +ENV JAVA_VERSION=8 \ |
| 4 | + JAVA_UPDATE=131 \ |
| 5 | + JAVA_BUILD=11 \ |
| 6 | + JAVA_HOME="/usr/lib/jvm/default-jvm" |
| 7 | +# update dpkg repositories and install tools |
| 8 | +RUN apt-get update |
| 9 | +RUN apt-get install -y openjdk-8-jdk |
| 10 | +RUN apt-get install -y --no-install-recommends apt-utils |
| 11 | +RUN apt-get install -y git |
| 12 | +RUN apt-get install -y wget |
| 13 | +RUN apt-get install -y curl |
| 14 | +RUN apt-get install -y graphviz |
| 15 | + |
| 16 | +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 |
| 17 | + |
| 18 | +# This is the line for the Jenkins prefix to set ... remember |
| 19 | +# to set the location in the reverse-proxy.conf |
| 20 | +ENV JENKINS_OPTS="--webroot=/var/cache/jenkins/war --prefix=/jenkins" |
| 21 | + |
| 22 | +#----------------------------------------------- |
| 23 | +# install Oracle Java if you want ... and |
| 24 | +# remove the line "RUN apt-get install -y openjdk-8-jdk" |
| 25 | +# above ... but openjdk is pretty good ! |
| 26 | +#----------------------------------------------- |
| 27 | +#------------ Download |
| 28 | +# ## ENV filename jdk-8u131-linux-x64.tar.gz |
| 29 | +# ## ENV downloadlink http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION}u${JAVA_UPDATE}-b${JAVA_BUILD}/d54c1d3a095b4ff2b6607d096fa80163/jdk-${JAVA_VERSION}u${JAVA_UPDATE}-linux-x64.tar.gz |
| 30 | +# ## RUN wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -O /tmp/$filename $downloadlink |
| 31 | +# ---- unpack java |
| 32 | +# ## ENV UNPACK_DIR=jdk1.8.0_131/ |
| 33 | +# ## RUN mkdir -p /opt/ && tar -zxf /tmp/$filename -C /opt/ && ln -s /opt/${UNPACK_DIR} /opt/java |
| 34 | +# ## ENV JAVA_HOME /opt/java |
| 35 | +#---------------------------------------- |
| 36 | +# install Maven |
| 37 | +#---------------------------------------- |
| 38 | +# get maven 3.2.0 |
| 39 | +RUN wget --no-verbose -O /tmp/apache-maven-3.2.5.tar.gz http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz |
| 40 | +# verify checksum |
| 41 | +RUN echo "b2d88f02bd3a08a9df1f0b0126ebd8dc /tmp/apache-maven-3.2.5.tar.gz" | md5sum -c |
| 42 | +# install maven |
| 43 | +RUN tar xzf /tmp/apache-maven-3.2.5.tar.gz -C /opt/ |
| 44 | +RUN ln -s /opt/apache-maven-3.2.5 /opt/maven |
| 45 | +ENV MAVEN_HOME /opt/maven |
| 46 | +ENV PATH $MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH |
| 47 | + |
| 48 | +RUN apt-get update && apt-get install -y zip unzip |
| 49 | +RUN rm -rf /opt/java/src.zip && rm -rf /tmp/$filename |
| 50 | +RUN rm -f /tmp/apache-maven-3.2.5.tar.gz |
| 51 | +#------------------------------ |
| 52 | +# install Jenkins |
| 53 | +#------------------------------ |
| 54 | +ENV JENKINS_HOME /var/jenkins_home |
| 55 | +ENV JENKINS_SLAVE_AGENT_PORT 50000 |
| 56 | +ARG user=jenkins |
| 57 | +ARG group=jenkins |
| 58 | +ARG uid=1000 |
| 59 | +ARG gid=1000 |
| 60 | +# Jenkins is run with user `jenkins`, uid = 1000 |
| 61 | +# If you bind mount a volume from the host or a data container, |
| 62 | +# ensure you use the same uid |
| 63 | +RUN groupadd -g ${gid} ${group} && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user} |
| 64 | +# Jenkins home directory is a volume, so configuration and build history |
| 65 | +# can be persisted and survive image upgrades |
| 66 | + |
| 67 | +VOLUME /var/jenkins_home |
| 68 | + |
| 69 | +# `/usr/share/jenkins/ref/` contains all reference configuration we want |
| 70 | +# to set on a fresh new installation. Use it to bundle additional plugins |
| 71 | +# or config file with your custom jenkins Docker image. |
| 72 | +RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d && mkdir /tmp |
| 73 | +ENV TINI_VERSION 0.14.0 |
| 74 | +ENV TINI_SHA 6c41ec7d33e857d4779f14d9c74924cab0c7973485d2972419a3b7c7620ff5fd |
| 75 | +# Use tini as subreaper in Docker container to adopt zombie processes |
| 76 | +RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini \ |
| 77 | + && echo "$TINI_SHA /bin/tini" | sha256sum -c - |
| 78 | + |
| 79 | +COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy |
| 80 | + |
| 81 | +# jenkins version being bundled in this docker image |
| 82 | +ARG JENKINS_VERSION |
| 83 | +ENV JENKINS_VERSION ${JENKINS_VERSION:-2.71} |
| 84 | + |
| 85 | +# jenkins.war checksum, download will be validated using it |
| 86 | +ARG JENKINS_SHA=71b2b5ba6d7fca261325682639ba604b7b889e7e |
| 87 | + |
| 88 | +# Can be used to customize where jenkins.war get downloaded from http://updates.jenkins-ci.org/download/war/2.57/jenkins.war |
| 89 | +ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war |
| 90 | + |
| 91 | +# could use ADD but this one does not check Last-Modified header neither does it allow to control checksum |
| 92 | +# see https://github.com/docker/docker/issues/8331 |
| 93 | +RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c - |
| 94 | + |
| 95 | + |
| 96 | +ENV JENKINS_UC https://updates.jenkins.io |
| 97 | +RUN chown -R ${user} "$JENKINS_HOME" /usr/share/jenkins/ref |
| 98 | + |
| 99 | +# for main web interface: |
| 100 | +EXPOSE 8080 |
| 101 | + |
| 102 | +ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log |
| 103 | + |
| 104 | +USER ${user} |
| 105 | + |
| 106 | +COPY jenkins-support /usr/local/bin/jenkins-support |
| 107 | +COPY jenkins.sh /usr/local/bin/jenkins.sh |
| 108 | + |
| 109 | +ENV JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.security.csrf.requestfield=crumb" |
| 110 | + |
| 111 | + |
| 112 | +ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"] |
| 113 | +#----------------------------------------------- |
| 114 | +# get all Plugins from existing Jenins |
| 115 | +#----------------------------------------------- |
| 116 | +# JENKINS_HOST=username:password@myhost.com:port |
| 117 | +# curl -sSL "http://$JENKINS_HOST/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/' |
| 118 | + |
| 119 | + |
| 120 | +# ---------------------------------------------------- |
| 121 | +COPY plugins.sh /usr/local/bin/plugins.sh |
| 122 | +COPY install-plugins.sh /usr/local/bin/install-plugins.sh |
| 123 | +# Install additional plugins |
| 124 | +COPY plugins.txt /usr/share/jenkins/ref/ |
| 125 | +RUN /usr/local/bin/plugins.sh /usr/share/jenkins/ref/plugins.txt |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | +USER root |
| 132 | + |
| 133 | +RUN apt-get clean |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
0 commit comments