Skip to content

Allow user to define command and entrypoint to services from config

What does this MR do?

Allow user to define command and entrypoint to services from config

Why was this MR needed?

Users can define services right inside of the config.toml. They can only define the name and alias of the service. When using services inside of the gitlab-ci.yml they can define entrypoint and command, however they can't do this inside of the config.toml file.

What's the best way to test this MR?

Docker

  1. Have the following .gitlab-ci.yml

    .gitlab-ci.yml
    image: docker:19.03
    
    variables:
      DOCKER_TLS_CERTDIR: "/certs"
      DOCKER_HOST: "tcp://docker:2376"
      DOCKER_CERT_PATH: "/certs/client"
      DOCKER_TLS_VERIFY: 1
    
    build:
      stage: build
      script:
      - echo $DOCKER_HOST
      - docker info
  2. Have the following config.toml

    config.toml
    [[runners]]
     ...
    [runners.docker]
      image = "alpine:3.12"
      privileged = true
      volumes = ["/cache", "/certs/client"]   
      [[runners.docker.services]]
      name = "docker:19.03.13-dind"
      command = ["--registry-mirror", "https://mirror.gcr.io"]
  3. You should see the https://mirror.gcr.io is used for the docker mirror from docker info command

Kubernetes

  1. Have the following .gitlab-ci.yml

    .gitlab-ci.yml
    image: docker:19.03
    
    variables:
      DOCKER_TLS_CERTDIR: "/certs"
      DOCKER_HOST: "tcp://docker:2376"
      DOCKER_CERT_PATH: "/certs/client"
      DOCKER_TLS_VERIFY: 1
    
    build:
      stage: build
      script:
      - echo $DOCKER_HOST
      - docker info
  2. Have the following config.toml

    config.toml
    [[runners]]
      ...
      [runners.kubernetes]
        image = "alpine:3.12"
        privileged = true
        [[runners.kubernetes.volumes.empty_dir]]
          name = "docker-certs"
          mount_path = "/certs/client"
          medium = "Memory"
        [[runners.kubernetes.services]]
          name = "docker:19.03.13-dind"
          alias = "docker"
          entrypoint = ["dockerd-entrypoint.sh"]
          command = ["--registry-mirror", "https://mirror.gcr.io"]
  3. You should see the https://mirror.gcr.io is used for the docker mirror from docker info command

What are the relevant issue numbers?

Edited by Steve Xuereb

Merge request reports