Skip to content

Instantly share code, notes, and snippets.

@ralexrdz
Created April 8, 2024 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralexrdz/97ab68555df038eebd3bde5fe658e162 to your computer and use it in GitHub Desktop.
Save ralexrdz/97ab68555df038eebd3bde5fe658e162 to your computer and use it in GitHub Desktop.
Gitlab Selfhosted Runner with Cache Configured

Have docker installed

https://docs.docker.com/engine/install/ubuntu/

Install gitlab runner

export arch=amd64
curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_${arch}.deb"
dpkg -i gitlab-runner_${arch}.deb
sudo chmod +x /usr/local/bin/gitlab-runner

Validate

gitlab-runner -v

Go To Gitlab Group

https://gitlab.com/groups/THE_GROUP/-/runners

  • Click "New Group Runner" Button>
  • Follow Form
  • Obtain token

Run registering command in terminal

sudo gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com/" \
  --token <THE TOKEN> \
  --executor "docker" \
  --docker-image alpine:latest \
  --description "<NAME YOUR RUNNER>"
  • Update config
sudo vim /etc/gitlab-runner/config.toml
  • Replace this values at the end of your gitlab runner
    volumes = ["/certs/client", "/mnt/cache:/cache", "/var/run/docker.sock:/var/run/docker.sock"]
    network_mode = "host"
    pull_policy = ["if-not-present"]
    shm_size = 0

Reset GitlabRunner service

sudo systemctl restart gitlab-runner.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment