I was curious about how can I host a gitlab instance on my own.
- GitLab Instance (of course)
- GitLab Runner
- GitLab CI/CD
Starting point -
export GITLAB_HOME=$(pwd)
docker compose up -d
Check the GitLab instance is healthy -
docker-compose exec gitlab /bin/bash -c "gitlab-ctl status"
docker exec -it gitlab-ce cat /etc/initial_root_password
Sign in @ git.localhost
username: root
password: ***
- Change the username root to something else
- Change the password to something else
...
docker exec -it gitlab-runner gitlab-runner register
gitlab-ce
is the container_name of the gitlab instance - see in compose file #L8
host: http://gitlab-ce
Two types of tokens for runners
- Shared runner
- Project-specific runner
token:
token
Runner name:
anything
you will need to use these tags in your job stages
tags:
whatever
description:
whatever
executor:
docker
See the services tag in gitlab-ci.yml
I am going to use dind (docker in docker) so set the image
docker-image:
docker:20.10.16
We are using DIND so we need to set the flags
- privileged (runner will get full access to the repository)
- network_mode (to see gitlab-instance from gitlab-runner DIND)
Otherwise, CI will fail like this
privileged = true
network_mode = "gitlab-network"
see in compose file #L38 ci-file
After registering the runner, you need to set the var
privileged = false
Check to login into the registry
docker login -u {username} -p {password} registry.git.localhost