Skip to content

Instantly share code, notes, and snippets.

@oofnikj
Created August 26, 2020 06:08
Show Gist options
  • Save oofnikj/92b705cf6de4df92bdd55c86d0c54e4a to your computer and use it in GitHub Desktop.
Save oofnikj/92b705cf6de4df92bdd55c86d0c54e4a to your computer and use it in GitHub Desktop.
GitLab multiarch docker build
# 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