mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
hack: base build scripts
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
45
hack/update-vendor
Executable file
45
hack/update-vendor
Executable file
@ -0,0 +1,45 @@
|
||||
#!/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=. \
|
||||
--frontend-opt target=update \
|
||||
--frontend-opt filename=./hack/dockerfiles/vendor.Dockerfile \
|
||||
--output type=local,dest=$output
|
||||
rm -rf ./vendor
|
||||
cp -R "$output/out/" .
|
||||
rm -rf $output
|
||||
;;
|
||||
*)
|
||||
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
||||
case $buildmode in
|
||||
"docker-buildkit")
|
||||
export DOCKER_BUILDKIT=1
|
||||
docker build --iidfile $iidfile -f ./hack/dockerfiles/vendor.Dockerfile --target update --force-rm .
|
||||
;;
|
||||
*)
|
||||
echo "buildctl or docker with buildkit support is required"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
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
|
||||
;;
|
||||
esac
|
Reference in New Issue
Block a user