Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab runner + autoscaling + scaled runner options

I'm using gitlab runner with docker+machine executor to fire up autoscaled runners on AWS. I would like to use docker-in-docker setup inside the runners to build containers, but I can't find out how to define the needed [runners.docker] properties for the spawned runners to enable docker usage.

Is it possible to somehow pass some config info to autoscaled runners?

like image 201
ronkot Avatar asked Feb 24 '17 06:02

ronkot


1 Answers

you just need this in your config.toml of your autoscale runner:

[runners.docker]
  privileged = true

I use docker-in-docker to build my own php containers for testing and store them in gitlabs registry. see https://gitlab.cwd.at/docker/php/builds/21582 for a build example and https://gitlab.cwd.at/docker/php/blob/master/.gitlab-ci.yml for the build definition

see here my current config - its using S3 for caching and digitalocean for the runners:

concurrent = 10

[[runners]]
  name = "ec2-autoscale-runner"
  url = "https://gitlab.mydomain.at/ci"
  token = "12345"
  executor = "docker+machine"
  limit = 10
  environment = ["COMPOSER_CACHE_DIR=/cache"]
  [runners.machine]
    OffPeakPeriods = [               # Set the Off Peak time mode on for:
      "* * 0-9,18-23 * * mon-fri *", # - Monday to Friday for 12am to 9am and 6pm to 11pm
      "* * * * * sat,sun *"          # - whole Saturday and Sunday
    ]
    OffPeakIdleCount = 0             # There must be 1 machine in Idle state - when Off Peak time mode is on
    OffPeakIdleTime = 3550           # Each machine can be in Idle state up to 1200 seconds (after this it will be removed) - when Off Peak time mode is on
    IdleCount = 0                    # There must be 5 machines in Idle state - when Off Peak time mode is off
    IdleTime = 3550                  # Each machine can be in Idle state up to 600 seconds (after this it will be removed) - when Off Peak time mode is off
    MaxBuilds = 100                    # Each machine can handle up to 100 builds in a row (after this it will be removed)
    MachineName = "auto-scale-%s"    # Each machine will have a unique name ('%s' is required)
    MachineDriver = "digitalocean"   # Docker Machine is using the 'digitalocean' driver
    MachineOptions = [
        "digitalocean-image=21937863",
        #"digitalocean-image=20969606",
        "digitalocean-access-token=12345",
        "digitalocean-region=fra1",
        "digitalocean-size=4gb",
        "digitalocean-private-networking",
        "digitalocean-ipv6=true"
    ]
  [runners.ssh]
    user = "root"
    identity_file = "/etc/gitlab-runner/id_rsa"
  [runners.docker]
    privileged = true
  [runners.cache]
    Type = "s3"
    ServerAddress = "s3.amazonaws.com"
    AccessKey = "1234"
    SecretKey = "1234"
    BucketName = "cwd-gitlab-cache"
    BucketLocation = "eu-central-1"
    Insecure = false
like image 105
Rufinus Avatar answered Sep 20 '22 14:09

Rufinus