version: "3.7"
services:
# Gitlab CI/CD can utilise Docker images with this running
dind:
image: docker:24-dind
restart: always
privileged: true
environment:
- DOCKER_TLS_CERTDIR=
- DOCKER_HOST=tcp://0.0.0.0:2375
command:
- --storage-driver=overlay2
- --tls=false
# Register the GitLab Runner, and write to config.toml. Service not needed after this has run
gitlab-register:
image: gitlab/gitlab-runner:latest
environment:
- CI_SERVER_URL=${CI_SERVER_URL} # Normally https://gitlab.com, change for Self-Hosted in .env
- REGISTER_NON_INTERACTIVE=true # Register without prompts
- REGISTRATION_TOKEN=${REGISTRATION_TOKEN} # This is the old way of registration, but here for backward compatibility
- TOKEN=${TOKEN} # New way of registering Gitlab runners
command: |
register --token ${TOKEN} --executor docker --docker-image=docker:24-dind --docker-volumes=/var/run/docker.sock:/var/run/docker.sock
volumes:
- gitlab-runner:/etc/gitlab-runner
# Customised Runner image with some tools installed for Shell, and hook into the DIND service above
gitlab-runner:
restart: always
image: papina/gitlab-runner:latest
environment:
- DOCKER_HOST=tcp://dind:2375
volumes:
- gitlab-runner:/etc/gitlab-runner
volumes:
gitlab-runner:
A single run service that will create the config.toml file in the volume shared with the actual gitlab runner.
gitlab/gitlab-runner:latest Docker image, which is used to register a GitLab Runner.Restart: Like the "dind" service, this service is configured to always restart automatically if it stops.
Image: This service uses the "papina/gitlab-runner:latest" Docker image, which is a customized GitLab Runner image with additional tools such as aws cli and ssm, terraform, and additional shell tools with the configurations.
Environment: The "DOCKER_HOST" environment variable is set to "tcp://dind:2375," indicating that this GitLab Runner should communicate with the Docker daemon in the "dind" service.
Volumes: The service mounts the "./gitlab-runner" directory into the container at "/etc/gitlab-runner."
gitlab-runner: Shared volume, will have /etc/gitlab-runner/config.toml configured
This Docker Compose file is designed to create a Gitlab runner environment for GitLab CI/CD integration, including a Docker-in-Docker (DinD) service, a GitLab Runner registration service, and a customized GitLab Runner with specific Docker configurations and tools installed. The services are orchestrated to work together for automated CI/CD tasks, and allow for Gitlab Pipelines to be run locally without using Gitlab compute usage
Content type
Image
Digest
sha256:8ea9945c5…
Size
613.1 MB
Last updated
almost 3 years ago
docker pull papina/gitlab-runner