Skip to content

Commit

Permalink
update circleci cross target
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Apr 6, 2021
1 parent a2a1de5 commit bd3e853
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
24 changes: 9 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
docker: [{image: 'docker:19.03-git'}]
environment:
DOCKER_BUILDKIT: 1
BUILDX_VERSION: "v0.5.1"
parallelism: 3
steps:
- checkout
Expand All @@ -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

Expand Down
20 changes: 19 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit bd3e853

Please sign in to comment.