From 0221c75ca954c3579d3601ff4e23d2a3d95bdfba Mon Sep 17 00:00:00 2001 From: Gareth Dunstone Date: Mon, 6 Jul 2020 14:39:41 +1000 Subject: [PATCH] trying to get to build without self-dependency --- .gitlab-ci.yml | 2 ++ original-gitlab-ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++++ readme.md | 6 +++++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 original-gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 142b710..6134acf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,7 @@ variables: - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY build:buildx-master: + image: docker:dind extends: .build only: refs: @@ -42,6 +43,7 @@ build:buildx-master: - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" --push . build:buildx: + image: docker:dind extends: .build only: variables: diff --git a/original-gitlab-ci.yml b/original-gitlab-ci.yml new file mode 100644 index 0000000..240c701 --- /dev/null +++ b/original-gitlab-ci.yml @@ -0,0 +1,46 @@ +image: jonoh/docker-buildx-qemu + +variables: + DOCKER_HOST: tcp://docker:2375/ + PLATFORM: local + DOCKER_IMAGE_TAG: latest + DOCKER_PREBUILD_CMD: echo + +services: + - docker:dind + +.docker_before_script: &docker_before_script + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker pull "$CI_REGISTRY_IMAGE" || true + - '[[ "$PLATFORM" != "local" ]] && update-binfmts --enable' + # Use docker-container driver to allow useful features (push/multi-platform) + - docker buildx create --driver docker-container --use + - docker buildx inspect --bootstrap + +build: + stage: build + before_script: *docker_before_script + script: + - $DOCKER_PREBUILD_CMD + - docker buildx build + --pull + --cache-from "$CI_REGISTRY_IMAGE" + --platform "$PLATFORM" + -t "$CI_REGISTRY_IMAGE:$DOCKER_IMAGE_TAG" + --push $EXTRA_BUILD_ARGS . + only: + - master + +build-unstable: + stage: build + before_script: *docker_before_script + script: + - $DOCKER_PREBUILD_CMD + - docker buildx build + --pull + --cache-from "$CI_REGISTRY_IMAGE" + --platform "$PLATFORM" + -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + --push $EXTRA_BUILD_ARGS . + except: + - master diff --git a/readme.md b/readme.md index 4db6865..90586a1 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,9 @@ # docker-buildx-qemu +> this is a fork of https://gitlab.com/ericvh/docker-buildx-qemu +> it has been modified to not depend on a gitlab-ci template repository. + + This Debian-based image allows you to easily build cross-platform images. It's been tested with GitLab CI on gitlab.com, but it should work anywhere that docker-in-docker already works, and with a binfmt_misc enabled kernel. @@ -34,7 +38,7 @@ build: DOCKER_TLS_CERTDIR: "" retry: 2 before_script: - - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # 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