Last active
January 23, 2025 18:27
-
-
Save bliuchak/233ec886374db630cd6a7327d82ff0f6 to your computer and use it in GitHub Desktop.
buf with go plugin (protoc-gen-go)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.15.7-alpine3.12 as golang | |
ENV GO111MODULE=on | |
RUN go get -u google.golang.org/[email protected] \ | |
&& go get -u github.com/golang/protobuf/[email protected] | |
FROM bufbuild/buf:0.36.0 as buf | |
FROM scratch | |
COPY --from=golang /go/bin/protoc-gen-go /go/bin/protoc-gen-go | |
COPY --from=buf /usr/local/bin/buf /usr/local/bin/buf | |
ENV PATH="/go/bin:${PATH}" | |
ENTRYPOINT ["/usr/local/bin/buf"] |
Thanks! I used this to make:
FROM golang:1.23.5-alpine3.21 as golang
ENV GO111MODULE=on
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest \
&& go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install \
connectrpc.com/connect/cmd/protoc-gen-connect-go@latest
FROM bufbuild/buf:1.50.0 as buf
FROM node:22-alpine3.20 as node
COPY --from=golang /go/bin/protoc-gen-go /go/bin/protoc-gen-go
COPY --from=golang /go/bin/protoc-gen-connect-go /go/bin/protoc-gen-connect-go
COPY --from=buf /usr/local/bin/buf /usr/local/bin/buf
RUN npm install --g @bufbuild/protoc-gen-es
ENV PATH="/go/bin:/usr/local/lib/node_modules/@bufbuild/protoc-gen-es/node_modules/.bin:${PATH}"
COPY ./sh/generate_inside_docker.sh /usr/bin/generate_inside_docker.sh
ENTRYPOINT ["/usr/bin/generate_inside_docker.sh"]
With generate_inside_docker.sh
being:
#!/bin/sh
buf build
buf generate
echo "Successfully generated protobuf files."
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for this