This one trick gives you unlimited CI minutes on Gitlab.

imichael

✨iMichael✨

Posted on August 3, 2018

This one trick gives you unlimited CI minutes on Gitlab.

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

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
imichael
✨iMichael✨

Posted on August 3, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related