protoc-gen-validate
protoc-gen-validate copied to clipboard
Unable to install protoc-gen-validate
Dockerfile:
FROM golang:1.15-buster
WORKDIR /data/
# install unzip
RUN apt-get update && apt-get install -y unzip
# install /usr/local/bin/protoc
RUN curl -L -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protoc-3.13.0-linux-x86_64.zip && \
unzip /tmp/protoc.zip -d /tmp/protoc/ && \
mv /tmp/protoc/bin/protoc /usr/local/bin/ && \
chmod +x /usr/local/bin/protoc
# install /go/bin/protoc-gen-go
RUN go get -u -v github.com/golang/protobuf/protoc-gen-go
# install /go/bin/protoc-gen-validate
# installing PGV can currently only be done from source
RUN go get -d github.com/envoyproxy/protoc-gen-validate && \
cd $GOPATH/src/github.com/envoyproxy/protoc-gen-validate && \
git log -n 1 && \
make build
Error:
cd validate && protoc -I . \
--plugin=protoc-gen-go=/go/src/github.com/envoyproxy/protoc-gen-validate/bin/protoc-gen-go \
--go_opt=paths=source_relative \
--go_out="Mvalidate/validate.proto=github.com/envoyproxy/protoc-gen-validate/validate,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers,Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor:." validate.proto
google/protobuf/descriptor.proto: File not found.
you can see the full log at https://github.com/ocavue/Dockerfiles/runs/1163927292#step:4:230
I might have an answer to this particular issue. You will need to add the contents of the protoc/include directory as well into /usr/local ie
RUN curl -L -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.13.1/protoc-3.13.1-linux-x86_64.zip && \ unzip -o /tmp/protoc.zip -d /usr/local bin/protoc && \ unzip -o /tmp/protoc.zip -d /usr/local 'include/*' && \ .. ..
BTW, If I check out the code to v0.4.1 (12 Aug 2020), then the installation has no issue.
Just ran some git bisect commands. It shows that this issue is caused by commit 538267e
I believe the reason is that github.com/golang/protobuf removed .proto files from their repository in this commit:
https://github.com/golang/protobuf/commit/f5983a527bbdbebe09855e1915b229f67e529e23 and the new test in 538267e triggers this error.
@akonradi I can think of two options to fix this issue:
- We can simply comment out those testing codes, so users will not fail when running
make build - It seems that users don't need to run
make buildlocally to installPGV? I tried to rungo get github.com/envoyproxy/protoc-gen-validateand everything is fine. What's the reason to let users runmake build? I feel like that I missed something...
Any better ideas?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@akonradi any update on this?
The error message is correct, whether or not the bisect is fingering that commit. The well-known types are required by validate.proto in order to generate correctly.
As @deepakkrishnak was saing, where you're installing protoc into your docker image, the tarball should contain a directory including these protos that are typically installed at /usr/local/include/google/....
All that said, make build shouldn't need to execute protoc to generate the validate.pb.go, since it's included in the repo.