-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
40 lines (37 loc) · 2.27 KB
/
docker-compose.yml
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
version: "3.5"
services:
dind: # Docker-in-Docker service to allow nested Docker usage
image: docker:20-dind # Use the Docker version 20 image with Docker-in-Docker enabled
restart: always # Ensure the service is always restarted in case of failure
privileged: true # Run the container in privileged mode to allow Docker daemon to run inside
environment:
DOCKER_TLS_CERTDIR: "" # Disable TLS for Docker daemon
command:
- --storage-driver=overlay2 # Use overlay2 storage driver for Docker
runner: # GitLab Runner service to execute CI/CD jobs
restart: always # Ensure the service is always restarted in case of failure
image: registry.gitlab.com/gitlab-org/gitlab-runner:alpine # Use the alpine-based GitLab Runner image
depends_on:
- dind # Ensure dind service is started before this service
environment:
- DOCKER_HOST=tcp://dind:2375 # Set Docker host to use Docker-in-Docker service
volumes:
- ./config:/etc/gitlab-runner:z # Mount local config directory to the GitLab Runner configuration directory
register-runner: # One-time service to register the GitLab Runner
restart: "no" # Do not restart the service after it completes
image: registry.gitlab.com/gitlab-org/gitlab-runner:alpine # Use the alpine-based GitLab Runner image
depends_on:
- dind # Ensure dind service is started before this service
environment:
- CI_SERVER_URL=${CI_SERVER_URL} # GitLab CI server URL (set through environment variable)
- REGISTRATION_TOKEN=${REGISTRATION_TOKEN} # Registration token for GitLab Runner (set through environment variable)
command: # Command to register the runner with the provided parameters
- register
- --non-interactive # Run the registration in non-interactive mode
- --locked=false # Allow the runner to pick up any available jobs
- --name=${RUNNER_NAME} # Set the runner name (from environment variable)
- --executor=docker # Use Docker executor
- --docker-image=docker:20-dind # Use Docker-in-Docker image for running jobs
- --docker-volumes=/var/run/docker.sock:/var/run/docker.sock # Mount Docker socket for Docker-in-Docker
volumes:
- ./config:/etc/gitlab-runner:z # Mount local config directory to the GitLab Runner configuration directory