Golden Codes - armanexplorer planet

Practical code snippets for Django, Python, Bash, Git and All!

View on GitHub

alt text

install Gitlab Runner software

Docs

register runner (after 16.0)

Docs

Runner Types Docs

docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register  --url https://example.com  --token glrt-XXXXXXXXXXXXXX
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com/" \
  --token "$RUNNER_TOKEN" \
  --executor "docker" \
  --docker-image alpine:latest \
  --description "docker-runner"

non-interactive example

gitlab-runner register \
    --non-interactive \
    --executor "shell" \
    --url "https://gitlab.com/" \
    --token "REDACTED"

Other than Docker-in-Docker (dind) solution (WARNING: Exposes the Docker engine of the host!)

docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register --docker-image "docker:20.10.16" --docker-volumes /var/run/docker.sock:/var/run/docker.sock

config

main ref

auto-scale

ref

docker image tags

Docker Hub Link

configure registry

Standard authentication methods

[[runners]]
  environment = ["DOCKER_AUTH_CONFIG={\"auths\":{\"registry.example.com:5000\":{\"auth\":\"bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ=\"}}}"]

Docker-in-Docker Mode

When you use Docker-in-Docker, the standard authentication methods do not work, because a fresh Docker daemon is started with the service.

cp ~/.docker/config.json /opt/.docker/

[[runners]]
  ...
  executor = "docker"
  [runners.docker]
    ...
    privileged = true
    volumes = ["/opt/.docker/config.json:/root/.docker/config.json:ro"]

configure docker mirror for dind service

Docs

Origin Issue

Monitoring runners

Docs

Dashboards

really good description about runner and worker concepts

ref

install GitLab Runner Manager in a container

docker run -d --name gitlab-runner --restart always \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

Gitlab Runner, runner, worker

Docs