Gitlab-Runner for build docker images to gitlab.tunex.io registry
version: 1.3.8
Created: 27.05.2023
Last edit: 08.12.2023
The current guide is necessary and should be involved before Deployment of Marionette Stack
Also, you need a root level access to the operation system of your PC, basic knowledge on Git and SSH as well, an account on TuneX Gitlab (address: gitlab.tunex.io).
If you don't match some of these requirements please read the manual carefully and use the explanations provided as links to external resources.
Gitlab-runner is a tool for executing instructions from a special ".gitlab-ci.yml" file. In the scope of current guide Girlab-runner created for certainly group to prepare docker images for futher deployment process of the Marionette Stack
For more information about gitlab runners follow the source: GitLab Runner | GitLab .
- 1 1. Prerequisites
- 2 2. Check VM connection
- 3 3. Required Environment on the VM
- 4 4. Install Gitlab Runner for build docker images
- 5 5. Register Group gitlab-runner
1. Prerequisites
1.1 VM to provide build docker images process
For new ‘building' server can be used:
Ubuntu 22.04+, SSD/HDD 200 GB, 8 cores, 16 RAM.
Note: Hardware resources (especially disk space) must be constantly monitored and should be maintained. The current guideline does not provide the maintenance.
1.2 TuneX Gitlab group for Marionette stack
TuneX gitlab Group has been created to deploy Marionette Stack. It contains reuired dependencies. First of all ask TuneX manager path to your group on the TuneX Gitlab and sign into gitlab.tunex.io Your gitlab Group url has the following view: gitlab.tunex.io/[group]
where [group] - your group name (lowercase with "-" instead whitespaces)
For example You got group name "My Project" and the url to your group on the TuneX Gitlab will be:
http://gitlab.tunex.io/my-project.
So, [group] = my-project
2. Check VM connection
Connect to the VM ( via SSH in terminal or command line prompt, if you need more details on launching it and connecting to remote machine or using Recovery Console please read How to Use SSH to Connect to a Remote Server in Linux or Windows article. Current guide uses linux terminal.
If this is the first time you access this VM via SSH, the user name should be 'root' and you wouldn't be asked for a password. If you're getting messages like 'wrong user name' etc. you need to find out your user name and/or password.
2.1. Connect VM through ssh
ssh root@<IP_address>
where <IP_address> - the address of the VM to provide build docker images process
You should got something like:
3. Required Environment on the VM
3.1 Set up Docker and logging limit
3.1.1. Install Docker engine
Connect to the VM as in the 2.1 step
Follow actual https://docs.docker.com/engine/install/ubuntu/ and you can skip current step.
Run command:
docker version
If you got the screen like:
follow 3.1.2. Set docker log limit skipping next commands in the current step.
Else if you got the answer similar to:
Update the apt package index and install packages to allow apt to use a repository over HTTPS:
apt-get update
apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Add Docker’s official GPG key:
Use the following command to set up the repository:
Install Docker Engine:
Check the docker engine was successfully installed through viewing the version:
the result should be like:
3.1.2. Set docker log limit
You should set docker log limit: max-size: 2m, max-file 3 (take for example: https://docs.docker.com/config/containers/logging/json-file/ ):
Below used the 'vim' text editor.
Note: If you have issues using this editor please use 'nano' as alternative or install visual shell for your remote machine
Write next log options data inside daemon.json file and save it
restart docker service to apply log limit:
check docker service to apply log limit:
You should get green status if service is OK:
4. Install Gitlab Runner for build docker images
4.1. Take hint for install and register Group gitlab-runner on TuneX Gitlab
Note: The Group gitlab-runner can be used for any CI/CD jobs for each project of your Group on TuneX Gitab. That is why the best way is to create one Group runner instead of several runners for each project inside your Group on TuneX Gitab.
4.1.1. Open left menu CI/CD -> Runners inside your Gitlab group on the TuneX Gitlab
4.1.2. Use "Show runner installation and registration instructions"
4.1.3. Use window for next guide steps to install and register runner
4.2. Connect to VM and install gitlab-runner
Run to connect the VM:
where [IP address] - the address of the VM for build docker images
You should got something like:
Below used "Download and install binary" from step 4.1.3
Install Gitlab runner (recommend binary install: Install GitLab Runner manually on GNU/Linux | GitLab ):
Give permissions to execute gitlab-runner
Run next command to add execute permissions:
create a GitLab CI user:
install and run as service:
4.3. Add user gitlab-runner to sudoers and to docker group
Enable sudo without password for gitlab-runner by next command:
!!! You should never edit /etc/sudoers with a regular text editor, such as Vim or nano, because they do not validate the syntax like the visudo editor
To the end of the opened /etc/sudoers file add this line:
e.g.:
and save changes
5. Register Group gitlab-runner
Connect to the VM again (in case you exit or loose connection):
where [IP address] - the address of the VM for deploy
5.1. Register Group gitlab-runner on VM for build docker images in TuneX Gitlab
5.1.1. Create gitlab-runner for build
Use "Command to register runner" from the step 4.1.3:
Here is command for register gitlab-runner:
where [Registration token] copied from "Command to register runner"
Answer to questions during regisrtation. Some important questions you should pay attention:
Question: “Enter a description for the runner:”
Answer: “YourCompanyName-builder”Question: “Enter tags for the runner:”
Answer: “builder”Question: “Enter en executor: parallels, ssh, docker, docker-ssh, kebrnetes:”
Answer: “docker”Question: “Enter the default Docker image(for example, ruby:2.7):”
Answer: “docker:latest”
Here is screen as example for answers :
5.1.2. Edit config for gitlab-runner for build:
Run next command to edit config.toml file:
Find inside the ‘config.toml’ file gitlab-runner by name entered as ‘description for the runner’ on the previous 5.1.1 step (e.g.: “MyCompanyName-builder“)
Change rows for parameters ‘privileged’ and ‘volumes’ as on the screen:
5.1.3. Restart gitlab-runner to apply changes
Run next command:
check gitlab-runner service status:
You should get green status if service is OK:
5.2. Check successful registration of the Group gitlab-runner on the TuneX Gitlab
5.2.1. Open left menu for your Group on TuneX Gitlab: CI/CD -> Runners
5.2.2 Check the gitlab-runner is available in the list of Group runners
Here is an example of available gitlab-runner with pointed VM IP to provide build docker images process, its tag and its description: