Created
August 26, 2020 06:08
-
-
Save oofnikj/92b705cf6de4df92bdd55c86d0c54e4a to your computer and use it in GitHub Desktop.
GitLab multiarch docker build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitLab multi-arch docker build template | |
# https://badgateway.qc.to/multi-architecture-docker-builds | |
variables: | |
CI_IMAGE: $DOCKER_HUB_USER/$CI_PROJECT_NAME | |
before_script: | |
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_TOKEN | |
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
- docker buildx create --use | |
build-master: | |
image: $DOCKER_HUB_USER/docker:buildx | |
stage: build | |
services: | |
- name: docker:dind | |
script: | |
- docker buildx build --push -t "$CI_IMAGE" | |
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 . | |
only: | |
- master | |
build-feature: | |
image: $DOCKER_HUB_USER/docker:buildx | |
stage: build | |
services: | |
- docker:dind | |
variables: | |
PLATFORM: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 | |
script: | |
- docker buildx build --push -t "$CI_IMAGE:$CI_COMMIT_REF_SLUG" | |
--platform "$PLATFORM" --cache-from "$CI_IMAGE:$CI_COMMIT_REF_SLUG" | |
--build-arg BUILDKIT_INLINE_CACHE=1 . | |
except: | |
- master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment