-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (43 loc) · 1.86 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Use Jenkins LTS
FROM jenkins/jenkins:lts
LABEL maintainer Edi Septriyanto <me@masedi.net> architecture="AMD64/x86_64"
LABEL jenkins-version="2.462.2-lts" build="04-Sep-2024"
USER root
ARG DOCKER_HOST_GID=${DOCKER_HOST_GID:-9999}
ENV DOCKER_HOST_GID=${DOCKER_HOST_GID}
# Modified entrypoint to allow for the use of a custom docker host.
COPY src/jenkins-docker.sh /usr/local/bin/jenkins-docker.sh
# Install Docker and dependencies.
RUN set -ex && \
apt-get -y update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common \
sudo && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "${ID}")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" && \
apt-get -y update && \
apt-get -y install docker-ce && \
rm -rf /var/lib/apt/lists/* && \
chmod +x /usr/local/bin/jenkins-docker.sh && \
# Add jenkins as docker group and sudoers
groupmod -g ${DOCKER_HOST_GID} docker && \
usermod -aG docker jenkins && \
echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers
USER jenkins
# Install Jenkins plugins.
COPY --chown=jenkins:jenkins src/plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli --verbose -f /usr/share/jenkins/ref/plugins.txt
# Copy email notification template.
COPY --chown=jenkins:jenkins src/email-templates /var/jenkins_home/
# Run the setup wizard.
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=true \
-Dpermissive-script-security.enabled=true"
# Set default admin user.
ENV JENKINS_OPTS="--argumentsRealm.roles.user=admin \
--argumentsRealm.passwd.admin=admin \
--argumentsRealm.roles.admin=admin"
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/jenkins-docker.sh"]