diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3be72010459c85fbe24c3bed968b2bff9a783c9d..21fa5a9016a00b0bf36a1ecc72084f38960d339e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,21 @@ -# When using dind, it's wise to use the overlayfs driver for -# improved performance. -variables: - DOCKER_DRIVER: overlay2 - DOCKER_TLS_CERTDIR: "/certs" - -default: - image: docker:19.03.12 +include: + - project: "e/infra/templates/infra-ci-cd-templates" + ref: main + file: "docker-build.yaml" - services: - - docker:19.03.12-dind - before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - tags: - - generic_privileged - -.build-docker: +.build-branch:docker: + extends: .build:docker script: - - echo "TARGET $TARGET, BRANCH $CI_COMMIT_BRANCH, COMMIT_REF_SLUG $CI_COMMIT_REF_SLUG, COMMIT_TAG $CI_COMMIT_TAG" + - echo "Building $TARGET target for $CI_COMMIT_BRANCH branch using $CI_COMMIT_REF_SLUG as docker image tag" - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_REF_SLUG" + - docker push --all-tags "$CI_REGISTRY_IMAGE$SUBPATH" + +.build-tag:docker: + extends: .build:docker + script: + - echo "Building $TARGET target for $CI_COMMIT_TAG tag using $CI_COMMIT_TAG as docker image tag" + - docker build --target $TARGET --pull -t "$CI_REGISTRY_IMAGE$SUBPATH:$CI_COMMIT_TAG" . + - docker push --all-tags "$CI_REGISTRY_IMAGE$SUBPATH" build-branch: stage: build @@ -27,7 +24,7 @@ build-branch: SUBPATH: '' only: - branches - extends: .build-docker + extends: .build-branch:docker build-branch-selfhost: stage: build @@ -37,7 +34,7 @@ build-branch-selfhost: only: - branches when: manual - extends: .build-docker + extends: .build-branch:docker build-tag: stage: build @@ -46,7 +43,7 @@ build-tag: SUBPATH: '' only: - tags - extends: .build-docker + extends: .build-tag:docker build-tag-selfhost: stage: build @@ -55,4 +52,4 @@ build-tag-selfhost: SUBPATH: '/selfhost' only: - tags - extends: .build-docker + extends: .build-tag:docker