Suppose I have repository on Gitlab and following deploying scheme:
- Setup docker and gitlab-runner with docker executor on host server.
- In
.gitlab-ci.yml
setup docker-compose to build and up my service together with dependencies. - Setup pipeline to be triggering by pushing commits to
production
branch.
As it advised in Gitlab guide I've placed in /etc/gitlab-runner/config.toml
following lines:
executor = "docker"
[runners.docker]
image = "alpine"
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
But volumes of my docker-compose.yml
are completely ignored. Suppose I have git repository with following structure:
.gitlab-ci.yml
docker-compose.yml
user_conf.d/app.conf
and have volumes: ./user_conf.d:/etc/nginx/user_conf.d
. When I check on /etc/nginx/user_conf.d
inside the container I find an empty folder intead of folder with app.conf
inside.
So the question is: how to properly pass volumes to docker container which is started from docker executer of Gitlab runner.
P.S. Configs are as following:
.gitlab-ci.yml:
image:
name: docker/compose:latest
services:
- docker:dind
stages:
- deploy
deploy:
stage: deploy
only:
- production
script:
- docker image prune -f
- docker-compose build --no-cache
- docker-compose up -d
docker-compose.yml:
services:
nginx:
image: jonasal/nginx-certbot:latest
restart: unless-stopped
env_file:
- ./nginx-certbot.env
ports:
- 80:80
- 443:443
volumes:
- /etc/letsencrypt
- ./user_conf.d:/etc/nginx/user_conf.d