Install Gitlab runner as a docker container
Mount a share from NAS
First click a NFS share on the NAS, then
sudo mkdir /var/lib/gitlab-runner
In /etc/fstab, add:
10.0.1.30:/raiden/gitlab-runner /var/lib/gitlab-runner nfs auto 0 0
sudo mount -a
Start gitlab-runner with spawning capabilities:
mkdir /var/lib/gitlab-runner/config sudo docker run -d --name gitlab-runner --restart always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/gitlab-runner/config:/etc/gitlab-runner \ gitlab/gitlab-runner:latest
docker docker.sock mount is to be able to spawn runner.
Setup the runner:
sudo docker exec -it gitlab-runner gitlab-runner register --docker-privileged
Here you get a lot of questions.
In my case I'm using https://gitlab.com/ci as the coordinator URI. The token you get from your projects page. I wasn't sure what to do with the else, but realized later.
So, I'm going to use gitlab/dind to be my runner.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci): https://gitlab.com/ci Please enter the gitlab-ci token for this runner: ***************** Please enter the gitlab-ci description for this runner: [22ee90a98372]: ensime-atom-docker Please enter the gitlab-ci tags for this runner (comma separated): main, dind Registering runner... succeeded runner=******_ Please enter the executor: docker+machine, docker-ssh+machine, docker, docker-ssh, parallels, shell, ssh, virtualbox: docker Please enter the default Docker image (eg. ruby:2.1): gitlab/dind:latest Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Here was the thing: I couldn't do a non-interactive registration
After this, I can go to my project at:
And I'll see this runner. I'll disable shared runners so I'm sure this one is used.
The way I did docker in docker (dind) dind image was old and I couldn't use it for multi-stage docker builds. So I needed to update the config to simply use the official
concurrent = 1 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "kostbevakningen-runner" url = "https://gitlab.com/" token = "******" executor = "docker" [runners.docker] tls_verify = false image = "docker:stable" privileged = true disable_cache = false volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"] shm_size = 0 [runners.cache] Insecure = false
Killed off old stuff and ran with:
sudo docker run -d --name gitlab-runner-kb --restart always -v /var/lib/gitlab-runner/kostbevakningen:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
- Also need to turn off shared runners per project in gitlab.com or it will use some random runner with ruby.
- Also need to check Run untagged jobs:
Another update. I needed another runner for another group in gitlab. Noticed that it didn't work to use the registration token directly in the config.toml. So better run a temp container to register:
docker run --rm -t -i -v /var/lib/gitlab-runner/woodenstake:/etc/gitlab-runner gitlab/gitlab-runner register
Enter the token from gitlab web there. This will generate the toml but the token there will be a new one.
Go in and edit the generated toml with proper settings.
Then start with something like:
services: gitlab-runner-kb: image: gitlab/gitlab-runner:latest container_name: gitlab-runner-kb volumes: - /var/run/docker.sock:/var/run/docker.sock - /var/lib/gitlab-runner/kostbevakningen:/etc/gitlab-runner restart: unless-stopped gitlab-runner-ws: image: gitlab/gitlab-runner:latest container_name: gitlab-runner-ws volumes: - /var/run/docker.sock:/var/run/docker.sock - /var/lib/gitlab-runner/woodenstake:/etc/gitlab-runner restart: unless-stopped
Get the latest posts delivered right to your inbox