====== Run GitLab CI Runner with Docker ======
- Run ''docker run -it --rm gitlab/gitlab-runner:ubuntu-v9.0.2 register''
# docker run -it --rm gitlab/gitlab-runner:ubuntu-v9.0.2 register
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://git.EXAMPLE.com/
Please enter the gitlab-ci token for this runner:
EXAMPLE # find at https://git.EXAMPLE.com/admin/runners
Please enter the gitlab-ci description for this runner:
[EXAMPLE00000]: EXAMPLE-digitalocean-auto-nyc3
Please enter the gitlab-ci tags for this runner (comma separated):
EXAMPLE,digitalocean,digitalocean-nyc3,linux
Whether to run untagged builds [true/false]:
[false]: true
Whether to lock Runner to current project [true/false]:
[false]: false
Registering runner... succeeded runner=EXAMPLE0
Please enter the executor: parallels, kubernetes, ssh, virtualbox, docker+machine, docker-ssh+machine, docker, docker-ssh, shell:
shell # skip the following interactive setup as we have to configure it manually
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
- Create ''/srv/gitlab-ci-runner/EXAMPLE/config/config.toml''
* DigitalOcean:
concurrent = 5
[[runners]]
name = "digitalocean-auto-nyc3"
url = "https://git.EXAMPLE.com/ci"
token = "FIND_AT https://git.EXAMPLE.com/admin/runners/EXAMPLE"
executor = "docker+machine"
environment = ["DOCKER_AUTH_CONFIG={...}"]
[runners.docker]
image = "ubuntu:xenial"
tls_verify = false
privileged = true
disable_cache = true
[runners.cache]
Insecure = false
[runners.machine]
IdleCount = 0
IdleTime = 1200
MachineDriver = "digitalocean"
MachineName = "orzgit-%s"
MachineOptions = [
"digitalocean-image=ubuntu-14-04-x64",
"digitalocean-ssh-user=root",
"digitalocean-access-token=EXAMPLE_EXAMPLE_EXAMPLE",
"digitalocean-region=nyc3",
"digitalocean-size=2gb",
"digitalocean-private-networking"
]
* List all images: $ curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer EXAMPLE_YOUR_TOKEN" "https://api.digitalocean.com/v2/images?page=1&per_page=1000&type=application"
* AWS EC2:
concurrent = 5
[[runners]]
name = "auto-aws-us-west-1"
url = "https://git.EXAMPLE.com/ci"
token = "FIND_AT https://git.EXAMPLE.com/admin/runners/EXAMPLE"
executor = "docker+machine"
environment = ["DOCKER_AUTH_CONFIG={...}"]
[runners.docker]
image = "ubuntu:xenial"
tls_verify = false
privileged = true
disable_cache = true
[runners.cache]
Insecure = false
[runners.machine]
IdleCount = 0
IdleTime = 1200
MachineDriver = "amazonec2"
MachineName = "orzgit-%s"
MachineOptions = [
"amazonec2-access-key=EXAMPLE",
"amazonec2-secret-key=EXAMPLE",
"amazonec2-region=us-west-1",
"amazonec2-ami=ami-615cb725",
"amazonec2-ssh-user=ubuntu",
"amazonec2-instance-type=t2.medium"
]
* AWS AMI is only available per region! https://cloud-images.ubuntu.com/releases/14.04/release-20150603/
- Save systemd configuration
[Unit]
Description=GitLab CI Runner (%i)
After=docker.service
Requires=docker.service
BindsTo=docker.service
[Service]
SyslogIdentifier=gitlab-ci-runner@%i.service
ExecStart=/usr/bin/systemd-docker run \
--rm \
--name gitlab-ci-runner.%i.service \
--volume /srv/gitlab-ci-runner/%i/config:/etc/gitlab-runner \
--volume /srv/gitlab-ci-runner/%i/home:/home/gitlab-runner \
--volume /srv/gitlab-ci-runner/%i/home:/root \
gitlab/gitlab-runner:ubuntu-v9.0.2
Restart=always
RestartSec=30s
Type=notify
NotifyAccess=all
TimeoutStartSec=120
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
- Enable and start service
# systemctl enable gitlab-ci-runner@digitalocean-auto-nyc3.service
# systemctl start gitlab-ci-runner@digitalocean-auto-nyc3.service
===== Notes =====
* Version
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner#runner-and-gitlab-ceee-compatibility
* Runner v9.0+ requires GitLab v9.0
* Runner v1.11.x supports GitLab v8.16.x ~ v9.5.x
* Private Docker Registry? Add ''DOCKER_AUTH_CONFIG''
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md#using-a-private-container-registry
* Self-signed SSL?
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/tls-self-signed.md
* Mount your certificate file at ''/etc/gitlab-runner/certs/git.EXAMPLE.com.crt'' with Docker volume
* Do NOT stop runners if it has started any VMs! Just wait until all VMs terminated. If you do...
- Terminate all machines on your own at DigitalOcean/AWS/YourCloud...
- Remove all folders in ''/srv/gitlab-ci-runner/EXAMPLE/home/.docker/machine/machines/''
===== See Alsos =====
* https://hub.docker.com/r/gitlab/gitlab-runner/tags/
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/docker.md
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/autoscaling.md
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md
* https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/autoscale.md
* https://docs.docker.com/machine/drivers/
* https://github.com/janeczku/docker-machine-vultr
{{tag>docker-install gitlab gitlab-ci}}