I'm trying to run protoc
command into a docker container.
I've tried using the gRPC image but protoc
command is not found:
/bin/sh: 1: protoc: not found
So I assume I have to install manually using RUN
instructions, but is there a better solution? An official precompiled image with protoc
installed?
Also, I've tried to install via Dockerfile but I'm getting again protoc: not found
.
This is my Dockerfile
#I'm not using "FROM grpc/node" because that image can't unzip
FROM node:12
...
# Download proto zip
ENV PROTOC_ZIP=protoc-3.14.0-linux-x86_32.zip
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/${PROTOC_ZIP}
RUN unzip -o ${PROTOC_ZIP} -d ./proto
RUN chmod 755 -R ./proto/bin
ENV BASE=/usr/local
# Copy into path
RUN cp ./proto/bin/protoc ${BASE}/bin
RUN cp -R ./proto/include/* ${BASE}/include
RUN protoc -I=...
I've done RUN echo $PATH
to ensure the folder is in path and is ok:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Also RUN ls -la /usr/local/bin
to check protoc
file is into the folder and it shows:
-rwxr-xr-x 1 root root 4849692 Jan 2 11:16 protoc
So the file is in /bin folder and the folder is in the path.
Have I missed something?
Also, is there a simple way to get the image with protoc
installed? or the best option is generate my own image and pull from my repository?
Thanks in advance.
Edit: Solved downloading linux-x86_64
zip file instead of x86_32
. I downloaded the lower architecture requirements thinking a x86_64
machine can run a x86_32
file but not in the other way. I don't know if I'm missing something about architecture requirements (It's probably) or is a bug.
Anyway in case it helps someone I found the solution and I've added an answer with the neccessary Dockerfile to run protoc
and protoc-gen-grpc-web
.
apt-get
install version 3.0.0, not 3.14.0. I will test if 3.0.0 works fine too. Thanks again! – Kelp