From 65e56a26ffb54039766c1a7e04ca97edc900a435 Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Tue, 24 May 2022 08:46:48 +0000 Subject: [PATCH] Update .gitlab-ci.yml --- .gitlab-ci.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8bb20a2..a851c3a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ # This template uses one generic job with conditional builds # for the default branch and all other (MR) branches. -docker-build: +docker-build-arm64: # Use the official docker image. image: docker:latest tags: @@ -42,3 +42,30 @@ docker-build: - if: $CI_COMMIT_BRANCH exists: - Dockerfile + +docker-build: + # Use the official docker image. + image: jdrouet/docker-with-buildx + stage: build + services: + - docker:dind + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + # Default branch leaves tag empty (= latest tag) + # All other branches are tagged with the escaped branch name (commit ref slug) + script: + - | + if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then + tag="" + echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" + else + tag=":$CI_COMMIT_REF_SLUG" + echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" + fi + - docker buildx create --use + - docker buildx build --push --platform linux/arm/v7,linux/386,linux/amd64 --tag "$CI_REGISTRY_IMAGE${tag}" . + # Run this job in a branch where a Dockerfile exists + rules: + - if: $CI_COMMIT_BRANCH + exists: + - Dockerfile