Skip to content

Instantly share code, notes, and snippets.

@paintmeyellow
Created March 30, 2022 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paintmeyellow/efe01eb25ebcea29755cde7315ea879c to your computer and use it in GitHub Desktop.
Save paintmeyellow/efe01eb25ebcea29755cde7315ea879c to your computer and use it in GitHub Desktop.
Protobuf compiler + Go plugin + buf in Docker container
version: "3"
services:
buf:
build:
context: .
dockerfile: docker/proto.Dockerfile
volumes:
- ./:/workspace
working_dir: /workspace
FROM bufbuild/buf:1.3.0 as buf
FROM golang:1.18-alpine
RUN apk add --no-cache build-base curl automake autoconf libtool git zlib-dev gcompat
ENV PROTOBUF_VERSION="3.19.3"
ENV PLUGIN_VERSION="1.27.1"
#install compiler https://github.com/protocolbuffers/protobuf
RUN mkdir -p /proto && PROTOC_ZIP=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip && \
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_ZIP} && \
unzip ${PROTOC_ZIP} -d /root/.local && rm -f ${PROTOC_ZIP}
#install go plugin https://github.com/protocolbuffers/protobuf-go
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PLUGIN_VERSION}
COPY --from=buf /usr/local/bin/buf /usr/local/bin/buf
ENTRYPOINT ["/usr/local/bin/buf"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment