Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jenkins in Docker
version: '2.4'
services:
jenkins:
image: ${JENKINS_IMAGE}
build: data/jenkins
ports:
- "${JENKINS_HOST_PORT:-8080}:8080"
- "33050:50000"
# mem_limit: 6g
environment:
JAVA_OPTS: |-
-Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-same-origin allow-scripts; default-src 'self'; script-src 'self' 'unsafe-inline'; img-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'"
-Dhudson.footerURL=https://jenkins.example.com
-Xms1g -Xmx3g -XX:+UseG1GC
EC2_INSTANCE_REGION: ${EC2_INSTANCE_REGION}
AWS_CONFIG_FILE: /opt/aws/config
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/lib64/libltdl.so.7:/usr/lib/libltdl.so.7
- /usr/local/bin/docker-compose:/usr/local/bin/docker-compose
- /var/jenkins_home:/var/jenkins_home
- ./data/jenkins/aws:/opt/aws
logging:
driver: awslogs
options:
awslogs-region: ${EC2_INSTANCE_REGION}
awslogs-group: docker
awslogs-stream: ${DEPLOYABLE_NAME}-jenkins
nginx:
depends_on:
- jenkins
FROM jenkins/jenkins:2.138.1
USER root
RUN apt-get update -y && apt-get install -y \
python-pip \
sudo
RUN pip install awscli --upgrade
CMD DOCKER_GID=$(stat -c '%g' /var/run/docker.sock) && \
groupadd -for -g ${DOCKER_GID} docker && \
usermod -aG docker jenkins && \
chown -R 1000 "${JENKINS_HOME}" && \
sudo -E -H -u jenkins bash -c /usr/local/bin/jenkins.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment