loading...

This one trick gives you unlimited CI minutes on Gitlab.

imichael profile image ✨iMichael✨ ・1 min read

Gitlab graciously provides 2,000 free minutes per month to all users on Gitlab.com (thanks Gitlab!). I deploy many times a day so it's quite easy to use all 2K minutes in a matter of days.

Here is how to get around that:

  • Spin up a new compute instance with Docker pre-installed. I recommend Digital Ocean, but Vultr is pretty good too.
  • Replace the CI_SERVER_URL value with one from your actual server URL. Go to the CI settings for your project and get your registration token under the "Runners" section. Then update REGISTRATION_TOKEN in the yml file.
  • Ssh into your server and save the code below to a file called docker-compose.yml.
  • Run docker-compose up -d
version: '2'
services:
  dind:
    restart: always
    privileged: true
    volumes:
    - /var/lib/docker
    image: docker:18.06.0-ce-dind
    command:
    - --storage-driver=overlay2

  runner:
    restart: always
    image: gitlab/gitlab-runner:alpine
    volumes:
    - ./gitlab/runner:/etc/gitlab-runner:Z
    environment:
    - DOCKER_HOST=tcp://dind:2375

  register-runner:
    restart: 'no'
    image: gitlab/gitlab-runner:alpine
    volumes:
    - ./gitlab/runner:/etc/gitlab-runner:Z
    command:
    - register
    - --non-interactived
    - --locked=false
    - --name=Docker Runner
    - --executor=docker
    - --docker-image=docker:18.06.0-ce-dind
    - --docker-volumes=/var/run/docker.sock:/var/run/docker.sock
    environment:
    - CI_SERVER_URL=https://XXXXXXXX.XXXXX
    - REGISTRATION_TOKEN=XXXXXXX

Posted on by:

imichael profile

✨iMichael✨

@imichael

Founder/CTO & Lead Software Engineer

Discussion

markdown guide
 

Hey Michael, thank you for the tip, I am running an issue:

register-runner_1  | FATAL: flag provided but not defined: -non-interactived 
stack_register-runner_1 exited with code 1
runner_1           | ERROR: Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory  builds=0

Some help would be really appreciated.

 

The docker-compose should be

  command:
    - register
    - --non-interactive
    - --locked=false

with out the d in interactive