├── Dockerfile ├── README.md └── docker-compose.yaml /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu as builder 2 | RUN apt-get update && apt-get install -y curl tar jq 3 | WORKDIR /build 4 | RUN curl -sLo hetzner.tar.gz $(curl --silent https://api.github.com/repos/JonasProgrammer/docker-machine-driver-hetzner/releases | jq -r '. | first | .assets[] | select(.name|contains("linux_amd64")).browser_download_url') 5 | RUN tar xf hetzner.tar.gz && chmod +x docker-machine-driver-hetzner 6 | 7 | FROM gitlab/gitlab-runner:latest 8 | COPY --from=builder /build/docker-machine-driver-hetzner /usr/bin 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto-scale CI jobs with Gitlab Runner and the Hetzner Docker Machine driver 2 | 3 | With this patched GitLab Runner image, you can auto-scale your CI jobs on Hetzner Cloud. The patch installs the [Hetzner Docker Machine driver](https://github.com/JonasProgrammer/docker-machine-driver-hetzner) and is available on [Docker Hub](https://hub.docker.com/r/mawalu/hetzner-gitlab-runner). 4 | 5 | You can follow the official [GitLab docs](https://docs.gitlab.com/runner/executors/docker_machine.html) for configuring the GitLab Runner with docker machine, just use this image as a drop in replacement for `gitlab/gitlab-runner`. 6 | 7 | See the example `config.toml` and `docker-compose.yaml` below for the hetzner specific docker machine options. 8 | 9 | ## Usage 10 | 11 | Use [this image](https://hub.docker.com/r/mawalu/hetzner-gitlab-runner) instead of the `gitlab/gitlab-runner` image and set `MachineDriver` to `hetzner` in your runner configuration. 12 | 13 | Example `config.toml`: 14 | 15 | ```toml 16 | concurrent = 1 17 | check_interval = 0 18 | 19 | [session_server] 20 | session_timeout = 1800 21 | 22 | [[runners]] 23 | name = "docker-machine" 24 | url = "https://gitlab.com" 25 | token = "your-token" 26 | executor = "docker+machine" 27 | [runners.docker] 28 | tls_verify = false 29 | image = "docker:latest" 30 | privileged = true 31 | disable_cache = false 32 | volumes = ["/cache"] 33 | shm_size = 536870912 34 | [runners.cache] 35 | [runners.machine] 36 | IdleCount = 0 37 | IdleTime = 1800 38 | MaxBuilds = 10 39 | MachineDriver = "hetzner" 40 | MachineName = "runner-%s" 41 | MachineOptions = [ 42 | "hetzner-api-token=hetzner-api-token", 43 | "hetzner-image=ubuntu-18.04", 44 | "hetzner-server-type=cx31", 45 | ] 46 | ``` 47 | 48 | Example `docker-compose.yaml`: 49 | 50 | ```yaml 51 | version: "3.8" 52 | 53 | services: 54 | hetzner-runner: 55 | image: mawalu/hetzner-gitlab-runner:latest 56 | volumes: 57 | - "./hetzner_config:/etc/gitlab-runner" 58 | ``` 59 | 60 | ### Docker Errors 61 | 62 | If you face docker problems at runtime (such as the one below), you can specify a Docker version in the `MachineOptions`. 63 | 64 | ```toml 65 | MachineOptions = [ 66 | "engine-install-url=https://releases.rancher.com/install-docker/19.03.9.sh", 67 | ] 68 | ``` 69 | 70 | Possible error that is caused by Docker: 71 | 72 | ```bash 73 | ERROR: Error creating machine: Error running provisioning: Unable to verify the Docker daemon is listening: Maximum number of retries (10) exceeded driver=hetzner name=runner-xxx-xxx operation=create 74 | ``` 75 | 76 | See [this issue](https://github.com/docker/machine/issues/4858) for more information. 77 | 78 | ## Versions 79 | 80 | Currently this image is build using the `gitlab/gitlab-runner:latest` image and the latest docker-machine hetzner plugin. If you need builds for another version feel free to open an PR. 81 | 82 | ## License 83 | 84 | MIT 85 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | 3 | services: 4 | hetzner-runner: 5 | image: mawalu/hetzner-gitlab-runner:latest 6 | volumes: 7 | - "./hetzner_config:/etc/gitlab-runner" 8 | --------------------------------------------------------------------------------