The docker image named golang:1.15
contains everything I require to generate grpc code using protoc. The only problem is that I want the output to be stable, by pinning the version of few packages (protoc-gen-go
, protoc-gen-go-grpc
, grpc
, protobuf
).
Here is my Dockerfile
FROM golang:1.15
WORKDIR /app
RUN export GO111MODULE=on # Enable module mode
RUN go mod init id
RUN go get google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0
RUN go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0
RUN go get google.golang.org/grpc@v1.35.0
RUN go get github.com/golang/protobuf@v1.4.3
RUN export PATH="$PATH:$(go env GOPATH)/bin"
The code-gen is done like so:
docker run -v "$$(pwd):/app" -v "$$(pwd)/pb:/pb" apigen protoc --go_out=../pb --go_opt=paths=source_relative --go-grpc_out=../pb --go-grpc_opt=paths=source_relative ./myproto.proto
This generates the code alright, but with this line on top // protoc-gen-go v1.25.0-devel
This is not the version I asked.
I tried changing the RUN go get .../protoc-gen-go@v1.25.0
to get v1.24.0
and it still shows the same output in the file, which means it doesn't use my modules at all, and must be using the ones from the golang
image.
How can I override what's in the image to pin the versions?