Last active
October 18, 2020 05:00
-
-
Save ivdunin/cd536db94860076872dd6d2c60c80fa0 to your computer and use it in GitHub Desktop.
Jenkins with Docker inside; Local docker registry and docker-compose for running jenkins
This file contains 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
#!/bin/bash | |
# We need the same GID for docker as on host machine | |
echo "Get docker group id..." | |
DOCKER_GID=`getent group docker | awk -F: '{ print $3 }'` | |
if [ -z ${DOCKER_GID} ]; | |
then | |
echo "Docker group id not found!"; | |
exit 1; | |
else | |
echo "Docker group found and group id = '$DOCKER_GID'"; | |
fi | |
echo "Building jenkins-docker image..." | |
docker build -t local-jenkins-docker -f Dockerfile --build-arg GID=$DOCKER_GID . |
This file contains 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
# Run local jenkins with docker | |
version: "3.7" | |
services: | |
jenkins: | |
image: local-jenkins-docker | |
configs: | |
- source: jenkins_log | |
target: /var/jenkins_home/log.properties | |
environment: | |
- JAVA_OPTS="-Djava.util.logging.config.file=/var/jenkins_home/log.properties" | |
volumes: | |
- jenkins_home:/var/jenkins_home | |
- /var/run/docker.sock:/var/run/docker.sock | |
networks: | |
- infrastructure | |
ports: | |
- 8080:8080 | |
- 50000:50000 | |
networks: | |
infrastructure: | |
volumes: | |
jenkins_home: | |
configs: | |
jenkins_log: | |
file: ./data/jenkins/log.properties |
This file contains 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
# Run local docker registry | |
version: "3.7" | |
services: | |
registry: | |
image: registry:2.7.1 | |
volumes: | |
- registry-data:/var/lib/registry | |
networks: | |
- registry | |
ports: | |
- 5000:5000 | |
deploy: | |
replicas: 1 | |
update_config: | |
parallelism: 1 | |
delay: 10s | |
restart_policy: | |
condition: on-failure | |
networks: | |
registry: | |
volumes: | |
registry-data: |
This file contains 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
version: '3.1' | |
services: | |
db: | |
image: postgres:11.5 | |
restart: always | |
environment: | |
POSTGRES_PASSWORD: xx1234 | |
POSTGRES_USER: test | |
POSTGRES_DB: test | |
ports: | |
- 5432:5432 | |
networks: | |
- internal | |
volumes: | |
- "/var/run/postgres/postgres.sock:/var/run/postgres/postgres.sock" | |
- "dbdata:/var/lib/postgresql/data" | |
redis: | |
image: redis:5.0.6 | |
restart: always | |
ports: | |
- 6379:6379 | |
networks: | |
- internal | |
rabbitmq: | |
image: rabbitmq:3.8.0-management | |
hostname: "rabbitmq" | |
environment: | |
RABBITMQ_DEFAULT_USER: "rabbitmq" | |
RABBITMQ_DEFAULT_PASS: "rabbitmq" | |
RABBITMQ_DEFAULT_VHOST: "/" | |
ports: | |
- "15672:15672" | |
- "5672:5672" | |
labels: | |
NAME: "rabbitmq1" | |
volumes: | |
dbdata: | |
networks: | |
internal: |
This file contains 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
FROM jenkins/jenkins:lts | |
# We need this for correct mapping groups | |
ARG GID=999 | |
USER root | |
ADD https://get.docker.com get-docker.sh | |
RUN sh get-docker.sh && \ | |
usermod -a -G docker jenkins && \ | |
apt-get clean && \ | |
groupmod -g $GID docker | |
USER jenkins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment