Skip to content

Instantly share code, notes, and snippets.

@guerzon

guerzon/config.toml

Created Sep 4, 2020
Embed
What would you like to do?
Configuration file for a Docker gitlab runner
concurrent = 10
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Docker runner"
url = "https://gitlab.localdomain.local/"
token = "tOkeNh3r3-"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "docker:19.03.12"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
@fgiudici95

This comment has been minimized.

Copy link

@fgiudici95 fgiudici95 commented Sep 7, 2020

Hi,
I have a question: how do you manage to use docker commands with a gitlab runner with docker as executor?

@guerzon

This comment has been minimized.

Copy link
Owner Author

@guerzon guerzon commented Sep 7, 2020

Hello,

Here is a stripped-down version of my .gitlab-ci.yml:

image: docker:19.03.12

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""
  REPO_NAME: "webapp"
  REGION: "ap-southeast-1"

services:
  - name: docker:19.03.12-dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]

stages:
  - build

build:
  stage: build
  script:
    - apk add --no-cache python3 py-pip
    - pip install awscli
    - $(aws ecr get-login --no-include-email --region "${REGION}")
    - echo "Building image for ${CI_COMMIT_TAG}"
    - docker build -t ${REPO_REGISTRY_URL}/${REPO_NAME}:${CI_COMMIT_TAG} -t ${REPO_REGISTRY_URL}/${REPO_NAME}:latest .
    - echo "Pushing image..."
    - docker push ${REPO_REGISTRY_URL}/${REPO_NAME}:${CI_COMMIT_TAG}
    - docker push ${REPO_REGISTRY_URL}/${REPO_NAME}:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment