variables: CI_BUILD_IMAGE: "registry.gitlab.com/ericvh/docker-buildx-qemu" CI_BUILDX_ARCHS: "linux/amd64,linux/arm64,linux/arm" .build: image: $CI_BUILD_IMAGE stage: build services: - name: docker:dind entrypoint: ["env", "-u", "DOCKER_HOST"] command: ["dockerd-entrypoint.sh"] variables: DOCKER_HOST: tcp://docker:2375/ DOCKER_DRIVER: overlay2 # See https://github.com/docker-library/docker/pull/166 DOCKER_TLS_CERTDIR: "" retry: 2 before_script: - | if [[ -z "$CI_COMMIT_TAG" ]]; then export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG} export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA} else export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE} export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG} fi - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY build:buildx-master: extends: .build only: refs: - master variables: - $CI_BUILDX_ARCHS script: # Use docker-container driver to allow useful features (push/multi-platform) - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel - docker buildx create --driver docker-container --use - docker buildx inspect --bootstrap - docker buildx ls - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" --push . build:buildx: extends: .build only: variables: - $CI_BUILDX_ARCHS except: refs: - master script: - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel - docker buildx create --driver docker-container --use - docker buildx inspect --bootstrap - docker buildx ls - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" --push .