We will deploy GitLab Runner on the same instance, so we should choose the Group Runner strategy.
The Group Runner will serve all projects in the ecommerce group, including both frontend and backend. This helps us manage and share resources more efficiently among related projects within the same group.
First, go to the ecommerce → Build → Runners group.
Click on New group runner to create one.
Create a new runner:
After creating it, you will see the steps to register the runner.
First, we must switch to the gitlab-runner user to ensure the runner can run correctly.
su gitlab-runner
cd
In steps 1 and 2, copy and run the commands, then fill in the information as shown below:
The configuration file will be saved at /home/gitlab-runner/.gitlab-runner/config.toml
.
vi /etc/gitlab-runner/config.toml
We proceed to edit concurrent = 2
so that the group runner can simultaneously run both the backend and frontend, then press Esc + :x
to save the changes.
In step 3, we run:
gitlab-runner run
You will see that the GitLab interface shows that the connection has been established.
🡇 Content 🡇
The connection has been successfully established, but sometimes, when you exit the command using Ctrl + C
, the instance will not receive triggers from the .gitlab-ci.yml
file. The best practice is to let it run in the background by running:
nohup gitlab-runner run > start-gitlab-runner.txt 2>&1 &
🡅 Content 🡅
That’s it! We have completed the registration process!