2018-03-26 10:52:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-09-14 18:36:19 +00:00
|
|
|
. $(dirname $0)/util
|
2018-03-26 10:52:36 +00:00
|
|
|
set -eu -o pipefail -x
|
|
|
|
|
2018-10-02 17:03:32 +00:00
|
|
|
: ${CONTINUOUS_INTEGRATION=}
|
|
|
|
|
|
|
|
progressFlag=""
|
|
|
|
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi
|
|
|
|
|
2019-01-26 06:29:13 +00:00
|
|
|
gogo_version=$(awk '$1 == "github.com/gogo/protobuf" { print $2 }' go.mod)
|
2018-09-14 18:36:19 +00:00
|
|
|
case $buildmode in
|
|
|
|
"buildkit")
|
2019-01-06 11:48:03 +00:00
|
|
|
output=$(mktemp -d -t buildctl-output.XXXXXXXXXX)
|
2018-10-02 17:03:32 +00:00
|
|
|
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. \
|
2019-03-20 10:18:16 +00:00
|
|
|
--opt build-arg:GOGO_VERSION=$gogo_version \
|
|
|
|
--opt target=update \
|
2019-10-18 07:36:14 +00:00
|
|
|
--opt filename=./hack/dockerfiles/generated-files.Dockerfile \
|
2019-03-19 03:16:27 +00:00
|
|
|
--output type=local,dest=$output
|
2019-01-06 11:48:03 +00:00
|
|
|
cp -R "$output/generated-files/" .
|
|
|
|
rm -rf $output
|
2018-09-14 18:36:19 +00:00
|
|
|
;;
|
2019-10-31 23:49:25 +00:00
|
|
|
"docker-buildkit")
|
2018-09-14 18:36:19 +00:00
|
|
|
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
2019-10-12 15:03:30 +00:00
|
|
|
export DOCKER_BUILDKIT=1
|
2019-10-18 07:36:14 +00:00
|
|
|
docker build --build-arg GOGO_VERSION=$gogo_version --iidfile $iidfile -f ./hack/dockerfiles/generated-files.Dockerfile --target update --force-rm .
|
2018-09-14 18:36:19 +00:00
|
|
|
iid=$(cat $iidfile)
|
|
|
|
cid=$(docker create $iid noop)
|
2018-03-26 10:52:36 +00:00
|
|
|
|
2019-01-06 11:48:03 +00:00
|
|
|
docker export $cid | tar -xf - --strip-components=1 generated-files
|
2018-03-26 10:52:36 +00:00
|
|
|
|
2018-09-14 18:36:19 +00:00
|
|
|
docker rm $cid
|
2018-03-26 10:52:36 +00:00
|
|
|
|
2018-09-14 18:36:19 +00:00
|
|
|
rm -f $iidfile
|
|
|
|
;;
|
2019-10-12 15:03:30 +00:00
|
|
|
*)
|
|
|
|
echo "Unsupported build mode: $buildmode" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2018-09-14 18:36:19 +00:00
|
|
|
esac
|