Update .gitlab-ci.yml

This commit is contained in:
TheJoKlLa 2022-05-24 08:46:48 +00:00
parent 15f7a949a4
commit 65e56a26ff

View File

@ -9,7 +9,7 @@
# This template uses one generic job with conditional builds # This template uses one generic job with conditional builds
# for the default branch and all other (MR) branches. # for the default branch and all other (MR) branches.
docker-build: docker-build-arm64:
# Use the official docker image. # Use the official docker image.
image: docker:latest image: docker:latest
tags: tags:
@ -42,3 +42,30 @@ docker-build:
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
exists: exists:
- Dockerfile - 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