In this post I would like to explain what I usually do to register a group runner. It is a very easy task, if you know the commands and the steps.
Let’s examine the scenario first: We have different projects on GitLab in one group (for me, this group is named according to my company “ersocon”). For each project we would like to set up CI builds and run them. Of course, we could easily use our free runners which are provided by GitLab. But in this case we usually don’t know what kind of machine will run our build and we can reach RAM/CPU limits for bigger applications. As well, there is a limit of minutes that you can run for free per month.
To overcome both limitations I prefer to go with a VM (DigitalOcean/Linode/ Scaleways, …) and install several group runners on this machine. In this post I will use a Debian distro with a pre-installed Docker and Docker-Compose Tool. Here are the steps to make it happen:
First, we create a directory to persist the configuration file for the runner:
sudo mkdir -p /srv/docker/gitlab-runner-ersocon-group/config
The directory path is not very important here. Just I am using the
/srv/docker folder for my application and name the application shared folder according to the name of the app.
We will use this directory to register a new runner like this:
docker run --rm -it -v /srv/docker/gitlab-runner-ersocon-group/config:/etc/gitlab-runner gitlab/gitlab-runner register
For the installation you will need to go into your Group administration account on gitlab.com and copy the token which is displayed in the CI/Runner section for your group. The command will prompt for some details and register a new runner with a proper configuration file in the directory that we have created previously.
We can use the configuration file now to create a new docker-compose.yml file with the following content:
version: '2'gitlab-runner-ersocon-group: image: gitlab/gitlab-runner:latest restart: always container_name: gitlab-runner-ersocon-group volumes: - /srv/docker/gitlab-runner-ersocon-group/config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock
Now, when we execute
docker-compose up -d we will have a nice runner, which is enabled for the whole group. It should now be visible in the Runners section in your projects on gitlab.com. For debugging you can omit the
-d parameter or attach to the logs after starting up by running