Skip to content

Commit

Permalink
Merge pull request #772 from vanstee/clean-generated-files-export
Browse files Browse the repository at this point in the history
`make generated-files` only copies over generated files from scratch container
  • Loading branch information
tonistiigi authored Jan 6, 2019
2 parents 34ff9c2 + f6c2487 commit a4e0df8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion hack/dockerfiles/generated-files.buildkit.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN --mount=target=/tmp/src \
git ls-files -m --others -- **/*.pb.go | tar -cf - --files-from - | tar -C /generated-files -xf -

FROM scratch AS update
COPY --from=generated generated-files /
COPY --from=generated /generated-files /generated-files

FROM gobuild-base AS validate
RUN --mount=target=/tmp/src \
Expand Down
14 changes: 5 additions & 9 deletions hack/update-generated-files
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"
gogo_version=$(awk '$1 == "github.com/gogo/protobuf" { print $2 }' vendor.conf)
case $buildmode in
"buildkit")
output=$(mktemp -d -t buildctl-output.XXXXXXXXXX)
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. \
--frontend-opt build-arg:GOGO_VERSION=$gogo_version \
--frontend-opt target=update \
--frontend-opt filename=./hack/dockerfiles/generated-files.buildkit.Dockerfile \
--exporter=local --exporter-opt output=.
--exporter=local --exporter-opt output=$output
cp -R "$output/generated-files/" .
rm -rf $output
;;
*)
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
Expand All @@ -31,14 +34,7 @@ case $buildmode in
iid=$(cat $iidfile)
cid=$(docker create $iid noop)

case $buildmode in
"docker-buildkit")
docker export $cid | tar -xf -
;;
*)
docker export $cid | tar -xf - --strip-components=1 generated-files
;;
esac
docker export $cid | tar -xf - --strip-components=1 generated-files

docker rm $cid

Expand Down

0 comments on commit a4e0df8

Please sign in to comment.