From 048a84614630f477611fc6e85a21e602c2c4d94b Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 5 Mar 2021 13:16:05 -0800 Subject: [PATCH] update circleci cross target Signed-off-by: Tonis Tiigi (cherry picked from commit bd3e853c7a8136137853532e42b1017de47237cf) Signed-off-by: Tibor Vass --- .circleci/config.yml | 24 +++++++++--------------- docker-bake.hcl | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 801ee5bf50..ca64e0d10f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,6 +42,7 @@ jobs: docker: [{image: 'docker:19.03-git'}] environment: DOCKER_BUILDKIT: 1 + BUILDX_VERSION: "v0.5.1" parallelism: 3 steps: - checkout @@ -55,21 +56,14 @@ jobs: - run: name: "Docker info" command: docker info - - run: - name: "Cross - build image" - command: | - docker build --progress=plain -f dockerfiles/Dockerfile.cross --tag cli-builder:$CIRCLE_BUILD_NUM . - - run: - name: "Cross" - command: | - name=cross-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX - docker run \ - -e CROSS_GROUP=$CIRCLE_NODE_INDEX \ - --name $name cli-builder:$CIRCLE_BUILD_NUM \ - make cross - docker cp \ - $name:/go/src/github.com/docker/cli/build \ - /work/build + - run: apk add make curl + - run: mkdir -vp ~/.docker/cli-plugins/ + - run: curl -fsSL --output ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64 + - run: chmod a+x ~/.docker/cli-plugins/docker-buildx + - run: docker buildx version + - run: docker context create buildctx + - run: docker buildx create --use buildctx && docker buildx inspect --bootstrap + - run: GROUP_INDEX=$CIRCLE_NODE_INDEX GROUP_TOTAL=$CIRCLE_NODE_TOTAL docker buildx bake cross --progress=plain - store_artifacts: path: /work/build diff --git a/docker-bake.hcl b/docker-bake.hcl index d450aaf29b..7443f4d627 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -32,8 +32,26 @@ target "dynbinary" { } } +variable "GROUP_TOTAL" { + default = "1" +} + +variable "GROUP_INDEX" { + default = "0" +} + +function "platforms" { + params = [USE_GLIBC] + result = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"]) +} + +function "glen" { + params = [platforms, GROUP_TOTAL] + result = ceil(length(platforms)/GROUP_TOTAL) +} + target "_all_platforms" { - platforms = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"]) + platforms = slice(platforms(USE_GLIBC), GROUP_INDEX*glen(platforms(USE_GLIBC), GROUP_TOTAL),min(length(platforms(USE_GLIBC)), (GROUP_INDEX+1)*glen(platforms(USE_GLIBC), GROUP_TOTAL))) } target "cross" {