Skip to content

Commit 7fbda52

Browse files
authored
Merge pull request #5911 from jsternberg/protobuf-generated-files
hack: aggregate protobuf includes to a separate stage
2 parents 43fc7e8 + 4fc3a2d commit 7fbda52

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

hack/dockerfiles/generated-files.Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ RUN --mount=type=bind,source=go.mod,target=/app/go.mod \
4343
set -e
4444
mkdir -p /opt/vtprotobuf
4545
go mod download github.com/planetscale/vtprotobuf
46-
cp -r $(go list -m -f='{{.Dir}}' github.com/planetscale/vtprotobuf)/include /opt/vtprotobuf
46+
cp -R $(go list -m -f='{{.Dir}}' github.com/planetscale/vtprotobuf)/include /opt/vtprotobuf
47+
chmod -R 0755 /opt/vtprotobuf
4748
EOT
4849

4950
FROM gobuild-base AS vendored
@@ -53,6 +54,12 @@ RUN --mount=type=bind,source=vendor,target=/app <<EOT
5354
find . -name '*.proto' | tar -cf - --files-from - | tar -C /opt/vendored/include -xf -
5455
EOT
5556

57+
FROM scratch AS protobuf
58+
COPY --link --from=protoc /opt/protoc /
59+
COPY --link --from=googleapis /opt/googleapis /
60+
COPY --link --from=vtprotobuf /opt/vtprotobuf /
61+
COPY --link --from=vendored /opt/vendored /
62+
5663
FROM gobuild-base AS tools
5764
RUN --mount=type=bind,source=go.mod,target=/app/go.mod \
5865
--mount=type=bind,source=go.sum,target=/app/go.sum \
@@ -62,10 +69,7 @@ RUN --mount=type=bind,source=go.mod,target=/app/go.mod \
6269
github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto \
6370
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
6471
google.golang.org/protobuf/cmd/protoc-gen-go
65-
COPY --link --from=protoc /opt/protoc /usr/local
66-
COPY --link --from=googleapis /opt/googleapis /usr/local
67-
COPY --link --from=vtprotobuf /opt/vtprotobuf /usr/local
68-
COPY --link --from=vendored /opt/vendored /usr/local
72+
COPY --link --from=protobuf / /usr/local
6973

7074
FROM tools AS generated
7175
RUN --mount=type=bind,target=github.com/moby/buildkit <<EOT

0 commit comments

Comments
 (0)