buildkit/hack/update-vendor

42 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
. $(dirname $0)/util
set -eu -o pipefail -x
: ${CONTINUOUS_INTEGRATION=}
progressFlag=""
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi
case $buildmode in
"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
docker cp $cid:/out/go.mod .
docker cp $cid:/out/go.sum .
docker cp $cid:/out/vendor .
docker rm $cid
rm -f $iidfile
;;
*)
echo "Unsupported build mode: $buildmode" >&2
exit 1
;;
esac