From 9afac5f684b918fb7010799474580866b3e1abec Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 25 Apr 2020 18:47:08 +0100 Subject: [PATCH] Add docker instalation. --- Dockerfile | 32 ++++++++++++++++++++++++-------- mvn-entrypoint.sh | 0 2 files changed, 24 insertions(+), 8 deletions(-) mode change 100644 => 100755 mvn-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 775162a..f71fd7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,43 @@ FROM jenkins/inbound-agent:4.3-4-jdk11 -# install maven like https://github.com/carlossg/docker-maven/tree/master/openjdk-11 +USER root + +# Install maven like in https://github.com/carlossg/docker-maven/tree/master/openjdk-11 . ARG MAVEN_VERSION=3.6.3 -ARG USER_HOME_DIR="/root" +ARG USER_HOME_DIR="/home/jenkins" ARG SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries - RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ && curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ && echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ && rm -f /tmp/apache-maven.tar.gz \ && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn - ENV MAVEN_HOME /usr/share/maven ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" - COPY mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh COPY settings-docker.xml /usr/share/maven/ref/ - -# configure maven COPY settings-maven.xml ${MAVEN_CONFIG}/settings.xml +# Install Docker like in https://medium.com/@manav503/how-to-build-docker-images-inside-a-jenkins-container-d59944102f30 . +RUN apt-get update -qq \ + && apt-get install -qqy apt-transport-https ca-certificates curl gnupg2 software-properties-common +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - +RUN add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/debian \ + $(lsb_release -cs) \ + stable" +RUN apt-get update -qq \ + && apt-get install docker-ce=18.06.3~ce~3-0~debian -y +RUN usermod -aG docker jenkins + +# Configure Maven. +RUN chown -R jenkins:jenkins ${MAVEN_CONFIG} +USER jenkins + +# Configure Docker. +# Nothing to do. + ENTRYPOINT ["/usr/local/bin/mvn-entrypoint.sh"] -CMD ["mvn"] \ No newline at end of file +CMD ["mvn"] diff --git a/mvn-entrypoint.sh b/mvn-entrypoint.sh old mode 100644 new mode 100755 -- 2.24.1