Last active
August 7, 2022 05:46
-
-
Save lattice0/ac47e45d8b781d06e0c777b626951df6 to your computer and use it in GitHub Desktop.
gitlab + runner installation process
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
# Install gitlab dockerized | |
export GITLAB_HOME=/srv/gitlab | |
sudo docker run --detach \ | |
--hostname gitlab.example.com \ | |
--publish 443:443 --publish 80:80 --publish 23:22 \ | |
--name gitlab \ | |
--restart always \ | |
--volume $GITLAB_HOME/config:/etc/gitlab \ | |
--volume $GITLAB_HOME/logs:/var/log/gitlab \ | |
--volume $GITLAB_HOME/data:/var/opt/gitlab \ | |
--shm-size 256m \ | |
gitlab/gitlab-ee:latest | |
# Takes a long time, lookup with | |
sudo docker logs -f gitlab | |
# When it looks ready, do | |
sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password | |
# to get the admin password so you can approve the new account. Do the account as your github username/password preferably | |
# Install virtualbox | |
# Install Ubuntu on virtualbox, and remove /home/$USER/.bash_logout file | |
# Install Windows on virtualbox, and follow https://docs.gitlab.com/runner/executors/virtualbox.html#checklist-for-windows-vms | |
# Do https://superuser.com/a/1606548 on windows | |
# Run `[System.Security.Principal.WindowsIdentity]::GetCurrent().Name` on windows to get the ssh machine machine/username and put into the registered instance (is it really needed? I dont think so) | |
# Do as admin: | |
reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe | |
# Install https://git-for-windows.github.io/ with the bash option so bash is available on power shell (IMPORTANT!) | |
# Register a runner instance (get the instance token on the panel and substitute below, ALSO edit the URL) | |
# For registering a docker instance (don't do this for virtual box vms) | |
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \ | |
--non-interactive \ | |
--executor "docker" \ | |
--docker-image alpine:latest \ | |
--url "http://192.168.1.11" \ | |
--registration-token "PROJECT_REGISTRATION_TOKEN" \ | |
--description "docker-runner" \ | |
--maintenance-note "Free-form maintainer notes about this runner" \ | |
--tag-list "docker,aws" \ | |
--run-untagged="true" \ | |
--locked="false" \ | |
--access-level="not_protected" | |
# I think it's better to install the runner without docker, cause the docker one cannot find virtualbox | |
curl -LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb | |
sudo apt install -y ./gitlab-runner_amd64.deb | |
# For registering a virtualbox instance interatively with docker (does not work after) | |
docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register | |
# For registering a virtualbox runner without docker | |
gitlab-runner register | |
# Add the `disable_strict_host_key_checking = true` line to `.gitlab-runner/config.toml` like this: | |
concurrent = 1 | |
check_interval = 0 | |
[session_server] | |
session_timeout = 1800 | |
[runners.ssh] | |
user = "lz" | |
password = "" | |
disable_strict_host_key_checking = true | |
Also add the cache directory to the runners section | |
cache_dir = "/home/your_username/cache" | |
output_limit = 90000 | |
example: | |
[[runners]] | |
name = "virtualbox_nondocker" | |
url = "http://192.168.1.20/" | |
token = "..." | |
executor = "virtualbox" | |
cache_dir = "/home/lz/cache" | |
output_limit = 90000 | |
# Create runner user | |
useradd gitlab-runner | |
# Add the runner user to docker | |
sudo usermod -aG docker gitlab-runner | |
# Verify that it works (that is, the runner can access docker) | |
sudo -u gitlab-runner -H docker info | |
Vagrant files: | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/jammy64" | |
config.vm.define "ubuntu" | |
config.vm.hostname = "ubuntu" | |
config.vm.provider "virtualbox" do |vb| | |
vb.name = "ubuntu" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment