hack: add binaries target
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>pull/2/head
parent
0487cc3ab7
commit
57857f09e1
@ -0,0 +1 @@
|
||||
bin
|
@ -1,10 +1,13 @@
|
||||
shell:
|
||||
./hack/shell
|
||||
|
||||
binaries:
|
||||
./hack/binaries
|
||||
|
||||
lint:
|
||||
./hack/lint
|
||||
|
||||
vendor:
|
||||
./hack/update-vendor
|
||||
|
||||
.PHONY: vendor lint shell
|
||||
.PHONY: vendor lint shell binaries
|
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. $(dirname $0)/util
|
||||
|
||||
: ${TARGETPLATFORM=$CLI_PLATFORM}
|
||||
: ${CONTINUOUS_INTEGRATION=}
|
||||
|
||||
set -ex
|
||||
|
||||
progressFlag=""
|
||||
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi
|
||||
|
||||
binariesDocker() {
|
||||
mkdir -p bin/tmp
|
||||
export DOCKER_BUILDKIT=1
|
||||
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
||||
|
||||
platformFlag=""
|
||||
if [ -n "$TARGETPLATFORM" ]; then
|
||||
platformFlag="--build-arg=TARGETPLATFORM=$TARGETPLATFORM"
|
||||
fi
|
||||
|
||||
docker build $platformFlag --target=binaries --iidfile $iidfile --force-rm .
|
||||
iid=$(cat $iidfile)
|
||||
containerID=$(docker create $iid copy)
|
||||
docker cp $containerID:/ bin/tmp
|
||||
mv bin/tmp/build* bin/
|
||||
rm -rf bin/tmp
|
||||
docker rm $containerID
|
||||
docker rmi -f $iid
|
||||
rm -f $iidfile
|
||||
}
|
||||
|
||||
binaries() {
|
||||
platformFlag=""
|
||||
if [ ! -z "$TARGETPLATFORM" ]; then
|
||||
platformFlag="--frontend-opt=platform=$TARGETPLATFORM"
|
||||
fi
|
||||
buildctl build $progressFlag --frontend=dockerfile.v0 \
|
||||
--local context=. --local dockerfile=. \
|
||||
--frontend-opt target=binaries $platformFlag \
|
||||
--output type=local,dest=./bin/
|
||||
}
|
||||
|
||||
case $buildmode in
|
||||
"buildkit")
|
||||
binaries
|
||||
;;
|
||||
"docker-buildkit")
|
||||
binariesDocker
|
||||
;;
|
||||
*)
|
||||
echo "buildctl or docker with buildkit support is required"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue