-
-
Save avraampiperidis/35c0238240747d4aaf6fb61266be17ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GITLAB_RUNNER_IMAGE=gitlab/gitlab-runner:alpine | |
GITLAB_HOST=localhost | |
GITLAB_RUNNER_REGISTRATION_TOKEN=my_runner_registration_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script registers a gitlab runner to the given gitlab host. | |
# Update GITLAB_RUNNER_REGISTRATION_TOKEN & GITLAB_HOST var in .env with your registration token and host | |
# Load env variables | |
. .env; | |
#get gitlab-runner container id | |
RUNNER_CONTAINER_ID=$(docker ps | grep "$GITLAB_RUNNER_IMAGE" | awk '{ print $1 }') | |
#register | |
docker exec -it $RUNNER_CONTAINER_ID gitlab-runner register \ | |
--non-interactive \ | |
--tls-ca-file=/certs/$GITLAB_HOST.crt \ | |
--registration-token $GITLAB_RUNNER_REGISTRATION_TOKEN \ | |
--locked=false \ | |
--description docker-gitlab-runner \ | |
--url https://$GITLAB_HOST \ | |
--executor docker \ | |
--docker-privileged=true \ | |
--docker-image docker:19.03.12 \ | |
--docker-network-mode host \ | |
--tag-list "docker,ci" \ | |
--docker-volumes "/var/run/docker.sock:/var/run/docker.sock" \ | |
--docker-volumes "/certs:/certs" \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment