Skip to content

Commit 4fc3a2d

Browse files
committed
hack: aggregate protobuf includes to a separate stage
This moves the aggregation of the various protobuf includes (binaries and include files) to a separate stage so the files can be retrieved more easily by external tools. Since the canonical way of retrieving the protobuf dependencies is to use this file and the dependencies can be quite complicated to retrieve, this makes it easier for outside contributors to retrieve the dependencies and copy them into their own repositories. This was possible before by using the `tools` target, but that would also include the entire `golang` image. Now you can retrieve just the `protobuf` target to get the binaries and the include files. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
1 parent 40a5c2d commit 4fc3a2d

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)