DEV Community

✨iMichael✨
✨iMichael✨

Posted on

10 2

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

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (5)

Collapse
 
robertpro profile image
José Roberto Meza Cabrera

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.

Collapse
 
narongdejsrn profile image
Narongdej Sarnsuwan

The docker-compose should be

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

with out the d in interactive

Collapse
 
stevefan1999personal profile image
Steve Fan

This.

This is not a trick.

Collapse
 
veslav3 profile image
Roy Honders

The blogpost is the real trick here. 😂

Collapse
 
imichael profile image
✨iMichael✨

Missed the joke

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay