# Use Jenkins base image
|
|
FROM jenkins/jenkins:latest
|
|
# FROM jenkins/jenkins:lts
|
|
|
|
# Switch to root user
|
|
USER root
|
|
|
|
# Update package lists and install necessary tools
|
|
RUN apt-get update && \
|
|
apt-get install -y sudo vim curl wget
|
|
|
|
|
|
# Set root password
|
|
RUN echo 'root:abc123' | chpasswd
|
|
|
|
# Add jenkins user to sudoers
|
|
RUN echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
|
|
# Install Docker CLI
|
|
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/debian/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
|
|
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && apt-get update
|
|
|
|
RUN curl -fsSL https://get.docker.com/ | sh
|
|
|
|
# Create the Docker Group
|
|
# RUN groupadd docker
|
|
|
|
# Add Jenkins User to Docker Group
|
|
RUN usermod -aG docker jenkins
|
|
|
|
# Switch back to the Jenkins user
|
|
USER jenkins
|