2017-05-25 23:26:11 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-01-26 06:29:13 +00:00
|
|
|
. $(dirname $0)/util
|
2017-05-25 23:26:11 +00:00
|
|
|
set -eu -o pipefail -x
|
|
|
|
|
2019-01-26 06:29:13 +00:00
|
|
|
: ${CONTINUOUS_INTEGRATION=}
|
|
|
|
|
|
|
|
progressFlag=""
|
|
|
|
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi
|
|
|
|
|
|
|
|
case $buildmode in
|
2020-07-25 03:36:55 +00:00
|
|
|
"buildkit")
|
|
|
|
output=$(mktemp -d -t buildctl-output.XXXXXXXXXX)
|
|
|
|
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. \
|
|
|
|
--opt target=update \
|
|
|
|
--opt filename=./hack/dockerfiles/vendor.Dockerfile \
|
|
|
|
--output type=local,dest=$output
|
|
|
|
rm -rf ./vendor
|
|
|
|
cp -R "$output"/out/* .
|
|
|
|
rm -rf $output
|
|
|
|
;;
|
|
|
|
"docker-buildkit")
|
|
|
|
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
docker build --iidfile $iidfile -f ./hack/dockerfiles/vendor.Dockerfile --target update --force-rm .
|
|
|
|
iid=$(cat $iidfile)
|
|
|
|
cid=$(docker create $iid noop)
|
|
|
|
rm -rf ./vendor
|
2019-01-26 06:29:13 +00:00
|
|
|
|
2020-07-25 03:36:55 +00:00
|
|
|
docker cp $cid:/out/go.mod .
|
|
|
|
docker cp $cid:/out/go.sum .
|
|
|
|
docker cp $cid:/out/vendor .
|
2019-01-26 06:29:13 +00:00
|
|
|
|
2020-07-25 03:36:55 +00:00
|
|
|
docker rm $cid
|
|
|
|
rm -f $iidfile
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported build mode: $buildmode" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2019-01-26 06:29:13 +00:00
|
|
|
esac
|