Last active
June 25, 2021 06:20
-
-
Save twasink/d52ef998b2a5b24cdfaa9e7358c5282f to your computer and use it in GitHub Desktop.
Jenkins Image, using Docker-in-Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We need Ruby to do a lot of stuff; let's install it here | |
# Using buster because that's what the Jenkins build is based on. | |
FROM ruby:2.7-buster as ruby | |
COPY --from=ruby / / | |
FROM jenkins/jenkins:lts-jdk11 | |
MAINTAINER Robert Watkins | |
USER root | |
RUN mkdir /var/log/jenkins | |
RUN mkdir /var/cache/jenkins | |
RUN chown -R jenkins:jenkins /var/log/jenkins | |
RUN chown -R jenkins:jenkins /var/cache/jenkins | |
# We also need to install Docker in Docker, because despite the fact that running Docker containers | |
# as part of Jenkins jobs is a standard practice, it is yet to become part of the standard | |
# installation process in the Jenkins image. | |
RUN apt-get update | |
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common | |
RUN curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | apt-key add - | |
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" | |
RUN apt-get update | |
# NB: The 996 is the group id for the docker group on the ECS server (Amazon Linux 2). | |
# Using the same group ID provides all of the necessary OS-level permissions and means | |
# we don't need to do any special hacks to get Docker running on the build server. | |
RUN groupadd -g 996 docker && usermod -a -G docker jenkins | |
RUN apt-get install -y docker-ce | |
# Okay - now for the Jenkins configuration. | |
USER jenkins | |
ENV JAVA_OPTS="-Xms1536m -Xmx1536m" | |
# "For 2.x-derived images, you may also want to" - we're 2.0 dervied, so we want this | |
RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state | |
# Put the log file into the log directory, which will be in the data volume | |
# Move the WAR out of the persisted jenkins data dir | |
# add a prefix to the URL, making it easier to route between various apps. | |
ENV JENKINS_OPTS="--logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --prefix=/jenkins" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment