Add support for multi-arch Docker containers
This commit is contained in:
parent
d614cbefe1
commit
f412d31d1c
1 changed files with 24 additions and 7 deletions
|
@ -1,17 +1,34 @@
|
||||||
image: docker:latest
|
# Docker Hub version e.g. here https://github.com/oofnikj/nuttssh/blob/master/.gitlab-ci.yml
|
||||||
|
image: oofnik/docker:buildx
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DOCKER_DRIVER: overlay2
|
PLATFORM: linux/amd64,linux/arm/v7
|
||||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
CI_IMAGE: $CI_REGISTRY_IMAGE
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
|
|
||||||
build:
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||||
|
- docker buildx create --use
|
||||||
|
|
||||||
|
build-master:
|
||||||
stage: build
|
stage: build
|
||||||
retry: 2
|
retry: 2
|
||||||
script:
|
script:
|
||||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
- docker buildx build --push -t "$CI_IMAGE"
|
||||||
- docker build -t $IMAGE_TAG .
|
--platform "$PLATFORM" --cache-from "$CI_IMAGE"
|
||||||
- docker push $IMAGE_TAG
|
--build-arg BUILDKIT_INLINE_CACHE=1 .
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
build-feature:
|
||||||
|
stage: build
|
||||||
|
retry: 2
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue