update circleci cross target

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit bd3e853c7a)
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tonis Tiigi 2021-03-05 13:16:05 -08:00 committed by Tibor Vass
parent 33dacda24f
commit 048a846146
2 changed files with 28 additions and 16 deletions

View File

@ -42,6 +42,7 @@ jobs:
docker: [{image: 'docker:19.03-git'}] docker: [{image: 'docker:19.03-git'}]
environment: environment:
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
BUILDX_VERSION: "v0.5.1"
parallelism: 3 parallelism: 3
steps: steps:
- checkout - checkout
@ -55,21 +56,14 @@ jobs:
- run: - run:
name: "Docker info" name: "Docker info"
command: docker info command: docker info
- run: - run: apk add make curl
name: "Cross - build image" - run: mkdir -vp ~/.docker/cli-plugins/
command: | - run: curl -fsSL --output ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64
docker build --progress=plain -f dockerfiles/Dockerfile.cross --tag cli-builder:$CIRCLE_BUILD_NUM . - run: chmod a+x ~/.docker/cli-plugins/docker-buildx
- run: - run: docker buildx version
name: "Cross" - run: docker context create buildctx
command: | - run: docker buildx create --use buildctx && docker buildx inspect --bootstrap
name=cross-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX - run: GROUP_INDEX=$CIRCLE_NODE_INDEX GROUP_TOTAL=$CIRCLE_NODE_TOTAL docker buildx bake cross --progress=plain
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
- store_artifacts: - store_artifacts:
path: /work/build path: /work/build

View File

@ -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" { 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" { target "cross" {