From 31062ed53cf7a2745bc622457f9819fb98fcf887 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 22 Jul 2020 14:59:41 +0200 Subject: add nocache variant --- gitlab-ci-template-nocache.yml | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 gitlab-ci-template-nocache.yml diff --git a/gitlab-ci-template-nocache.yml b/gitlab-ci-template-nocache.yml new file mode 100644 index 0000000..e5b8cae --- /dev/null +++ b/gitlab-ci-template-nocache.yml @@ -0,0 +1,45 @@ +# https://blog.callr.tech/building-docker-images-with-gitlab-ci-best-practices/ +# comments dropped, updated for podman builds +# this variant builds without caching + +image: registry.gitlab.com/kraxel/podman-docker-builder:latest + +stages: + - build + - push + +before_script: + - podman login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + +Build: + stage: build + script: + - > + podman build + --build-arg VCS_REF=$CI_COMMIT_SHA + --build-arg VCS_URL=$CI_PROJECT_URL + --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + . + - podman push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + +Push latest: + variables: + GIT_STRATEGY: none + stage: push + only: + - master + script: + - podman pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + - podman tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest + - podman push $CI_REGISTRY_IMAGE:latest + +Push tag: + variables: + GIT_STRATEGY: none + stage: push + only: + - tags + script: + - podman pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + - podman tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + - podman push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME -- cgit