FROM jenkins/inbound-agent:4.3-4-jdk11 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="/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/ 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"]