Installation d'un Gitlab Runner pour CI/CD avec Docker
Par pepin le vendredi, décembre 13 2019, 22:41 - Git/Gitlab - Lien permanent
Installation du container docker
docker run -d --name gitlab-runner-config \ -v /etc/gitlab-runner \ busybox:latest \ /bin/true docker run -d --name gitlab-runner --restart always \ -v /var/run/docker.sock:/var/run/docker.sock \ --volumes-from gitlab-runner-config \ gitlab/gitlab-runner:latest
Une fois ceci fait, il faut enregistrer le runner
pour cela allez dans la pace ci/cd de votre projet gitlab, exemple pour moi :
http://death.maison.local/gitlab/pvalois/menu/-/settings/ci_cd
la dans la partie runner, vous avez un token de connexion.
exécutez :
docker exec -t -i gitlab/gitlab-runner bash gitlab-runner register
et répondez aux question. Pour l'instant, j'ai repondu comme suit :
Runtime platform arch=amd64 os=linux pid=6 revision=577f813d version=12.5.0 Running in system-mode. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://death.maison.local/gitlab/
Please enter the gitlab-ci token for this runner:
LfFNGi6eHry7nSMcZUL3
Please enter the gitlab-ci description for this runner: [9b9d8d60086e]:
docker-runner 9b9d
Please enter the gitlab-ci tags for this runner (comma separated):
docker
Registering runner... succeeded runner=LfFNGi6e
sur ces deux lignes, je n'ai rien répondu, rien de précis ne m'étant venu à l'idée, mais de toute façon ici, ce n'est pas obligatoire, c'est pour retrouver ses billes
Please enter the executor: custom, docker, docker-ssh, parallels, shell, ssh, docker+machine, kubernetes, virtualbox, docker-ssh+machine:
docker
Please enter the default Docker image (e.g. ruby:2.6):
ruby:2.6
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Pour la réponse "docker" c'est logique. Gitlab-ci pourra lancer un nouveau container à chaque fois qu'il veut tester un build, et le détruira ensuite. c'est un comportement classique en ci/cd.
Pour la réponse "ruby:2.6", j'ai laissé simplement le défaut suggéré, je n'ai pas choisi encore quelle image type je voudrais utiliser.
Il suffit maintenant dans notre .gitlab-ci.yaml de spécifier pour un job :
tag: - docker
et notre runner sera apparié au job.
Tout ça pour dire que mon test a réussi et que donc je peux passer à la suite !