diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-12-17 17:54:05 +0100 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2018-12-20 10:28:32 +0100 |
commit | f3ddda618ec86650ed85f8b140a5db1394676748 (patch) | |
tree | 9749f2f48c10c0b719837f16c386fc0f7ad23151 /.gitlab-ci.yml | |
parent | b689dc5081493377a31759d24a8dc9fcde12948a (diff) |
gitlab-ci: Use kaniko instead of docker-in-docker for image generation
kaniko can also work in unprivileged runners.
Based on v2 of
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/92 .
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r-- | .gitlab-ci.yml | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d1960fb..4f63840 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,16 +24,30 @@ stages: debian-testing: stage: docker-image - image: docker:stable - services: - - docker:dind - before_script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] script: - - docker pull "$IMAGE_LOCAL" || - ((docker pull "$IMAGE_MAIN" && docker tag "$IMAGE_MAIN" "$IMAGE_LOCAL") || - docker build -t "$IMAGE_LOCAL" .gitlab-ci; - docker push "$IMAGE_LOCAL") + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + - mkdir kaniko-context + - | + echo "FROM $IMAGE_LOCAL" > kaniko-context/Dockerfile + # If the image exists in the local registry, skip to the build-and-test job + set +e + set -x + /kaniko/executor --context kaniko-context --no-push && exit 0 + set +x + set -e + - | + echo "FROM $IMAGE_MAIN" > kaniko-context/Dockerfile + # Try to re-use the image from the main repository's registry, and if + # that fails, generate a local image from scratch + set +e + set -x + /kaniko/executor --context kaniko-context --destination $IMAGE_LOCAL && exit 0 + set +x + set -e + - /kaniko/executor --context $CI_PROJECT_DIR/.gitlab-ci --destination $IMAGE_LOCAL image: $IMAGE_LOCAL |