Skip to content

Instantly share code, notes, and snippets.

@mrnonz
Last active October 29, 2019 09:41
Show Gist options
  • Save mrnonz/f8c908fe710ddd4464fa7f4d06e62f12 to your computer and use it in GitHub Desktop.
Save mrnonz/f8c908fe710ddd4464fa7f4d06e62f12 to your computer and use it in GitHub Desktop.
Startup script for VM to registration Gitlab Runner
sudo apt-get update
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
curl -sSL https://get.docker.com/ | sh
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
gitlab-runner register -h
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "CHANGE_GITLAB_RUNNER_TOKEN_HERE" \
--executor "docker" \
--docker-image alpine \
--description "$(hostname)" \
--run-untagged \
--docker-privileged \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--locked="false"
sudo sed -i 's/concurrent = 1/concurrent = 2/' /etc/gitlab-runner/config.toml
sudo gitlab-runner restart
@mrnonz
Copy link
Author

mrnonz commented Jul 24, 2019

and shutdown script like these

sudo gitlab-runner unregister --all-runners

apply to shutdown-script meta

@mrnonz
Copy link
Author

mrnonz commented Oct 29, 2019

For GCS caching step

sudo apt-get update
 
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
 
sudo chmod +x /usr/local/bin/gitlab-runner
 
curl -sSL https://get.docker.com/ | sh
 
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
 
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
 
sudo gitlab-runner start
 
gitlab-runner register -h
 
echo "{\"type\": \"service_account\",\"project_id\"........." > /etc/service_account.json
 
sudo gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com/" \
  --registration-token "CHANGE_GITLAB_RUNNER_TOKEN_HERE" \
  --executor "docker" \
  --docker-image alpine:3 \
  --description "$(hostname)" \
  --tag-list "LIST,OF,RUNNER,TAGS" \
  --run-untagged \
  --locked="false" \
  --cache-type="gcs" \
  --cache-gcs-credentials-file="/etc/service_account.json" \
  --cache-gcs-bucket-name="GCS_BUCKET_NAME" \
  --cache-shared \
  --cache-path="gitlab-ci/cache"
 
sudo sed -i 's/concurrent = 1/concurrent = 2/' /etc/gitlab-runner/config.toml
 
sudo gitlab-runner restart

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