-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding utilities to run buf in Docker.
- Loading branch information
Showing
2 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
# Setup Go alpine to install protoc-gen-go plugin. | ||
FROM golang:alpine AS golang | ||
ENV GO111MODULE=on | ||
|
||
RUN go install google.golang.org/protobuf/cmd/[email protected] | ||
|
||
# Setup Buf to have buf available. | ||
FROM bufbuild/buf:1.45.0 AS buf | ||
|
||
# Add diffutils and its dependencies, which are needed by buf format. | ||
FROM alpine AS diffutils | ||
RUN apk add --no-cache diffutils | ||
RUN mkdir /deps && ldd /usr/bin/diff | tr -s '[:blank:]' '\n' | grep '^/' | xargs -I '{}' cp --parents '{}' /deps | ||
|
||
# Wrap everything together in a scratch container to do all things 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 | ||
COPY --from=diffutils /usr/bin/diff /usr/bin/diff | ||
COPY --from=diffutils /deps / | ||
ENV PATH="/go/bin:${PATH}" | ||
ENTRYPOINT ["/usr/local/bin/buf"] |