diff --git a/.dockerignore b/.dockerignore index e660fd93..7d1c8f17 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ bin/ +cross-out/ diff --git a/Makefile b/Makefile index 3fd67bec..a7751d3f 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ shell: binaries: ./hack/binaries +binaries-cross: + EXPORT_LOCAL=cross-out ./hack/cross + install: binaries mkdir -p ~/.docker/cli-plugins cp bin/buildx ~/.docker/cli-plugins/docker-buildx diff --git a/hack/cross b/hack/cross new file mode 100755 index 00000000..d1d9b5d9 --- /dev/null +++ b/hack/cross @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +. $(dirname $0)/util + +: ${TARGETPLATFORM=linux/amd64,linux/arm/v7,linux/arm64,darwin/amd64,windows/amd64,linux/ppc64le,linux/s390x} +: ${CONTINUOUS_INTEGRATION=} +: ${EXPORT_LOCAL=} + +set -ex + +exportFlag="" +if [ -n "$EXPORT_LOCAL" ]; then + exportFlag="--output=type=local,dest=$EXPORT_LOCAL" +fi + +progressFlag="" +if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; +fi + +buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. --opt platform=$TARGETPLATFORM $exportFlag --opt target=binaries \ No newline at end of file