Skip to content

Instantly share code, notes, and snippets.

@darmawan01
Last active February 24, 2022 10:36
Show Gist options
  • Save darmawan01/b600707ba10d1c2f4267717c69904336 to your computer and use it in GitHub Desktop.
Save darmawan01/b600707ba10d1c2f4267717c69904336 to your computer and use it in GitHub Desktop.
Run Our Own Gitlab Runner
#!/bin/bash
# See at link below for update
# https://gist.github.com/darmawan01/b600707ba10d1c2f4267717c69904336
if [ "$1" = "init" ]; then
docker run -d --name gitlab-runner \
--restart always \
--privileged \
-v $(pwd):/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
elif [ "$1" = "create" ] && [ -n "$2" ] && [ -n "$3" ]; then
docker run --rm -ti -v $(pwd):/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--name $2 \
--url https://gitlab.com/ \
--registration-token "$3" \
--tag-list "docker" \
--run-untagged \
--executor docker \
--docker-image "docker:latest" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--docker-privileged
else
echo "Usage !"
echo "./runner.sh init <- Init the gitlab runner"
echo "./runner.sh create <runner-name> <runner-token> <- Create a runner"
fi
@darmawan01
Copy link
Author

darmawan01 commented Feb 24, 2022

Adding runner access the server to automation

  • Generate The ssh key
ssh-keygen -t ed25519 -C "[email protected]"
  • Copy your private key to gitlab variable
  • Copy your public key to server .ssh/authorization_keys

@darmawan01
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment