Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for nanopb #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ test.pb.go
test.rb
**/gen/*
pb-*
.idea/

14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FROM golang:$go-alpine$alpine AS build
ARG grpc
ARG grpc_java
ARG grpc_web=1.0.7
ARG nanopb=0.4.1

RUN set -ex && apk --update --no-cache add \
bash \
Expand Down Expand Up @@ -62,6 +63,11 @@ RUN curl -sSL https://github.com/grpc/grpc-web/releases/download/${grpc_web}/pro
-o /tmp/grpc_web_plugin && \
chmod +x /tmp/grpc_web_plugin

RUN curl -sSL https://jpa.kapsi.fi/nanopb/download/nanopb-${nanopb}-linux-x86.tar.gz \
-o /tmp/nanopb.tar.gz && \
mkdir -p /tmp/nanopb && \
tar -xzf /tmp/nanopb.tar.gz --strip 1 -C /tmp/nanopb

FROM alpine:3.9 AS protoc-all

RUN set -ex && apk --update --no-cache add \
Expand All @@ -70,7 +76,10 @@ RUN set -ex && apk --update --no-cache add \
libc6-compat \
ca-certificates \
nodejs \
nodejs-npm
nodejs-npm \
python \
py2-pip && \
pip install protobuf
Comment on lines +80 to +82
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why the python packages are necessary?
does the plugin require them? because looking at the download page it seems like all the dependencies are included, no?

Additionally, I wonder if we should specify the version of this packages.


# Add TypeScript support

Expand All @@ -90,6 +99,9 @@ COPY --from=build /go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swag

COPY --from=build /go/src/github.com/envoyproxy/protoc-gen-validate/ /opt/include/
COPY --from=build /go/src/github.com/mwitkow/go-proto-validators/ /opt/include/github.com/mwitkow/go-proto-validators/
COPY --from=build /tmp/nanopb/generator/ /usr/local/lib/protoc-gen-nanopb/
COPY --from=build /tmp/nanopb/generator/nanopb/ /opt/include/nanopb/options/
COPY --from=build /tmp/nanopb/generator/proto/nanopb.proto /opt/include/nanopb/nanopb.proto

ADD all/entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/entrypoint.sh
Expand Down
5 changes: 4 additions & 1 deletion all/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ DOCS_FORMAT="html,index.html"
GEN_TYPESCRIPT=false
LINT=false
LINT_CHECKS=""
SUPPORTED_LANGUAGES=("go" "ruby" "csharp" "java" "python" "objc" "gogo" "php" "node" "web" "cpp" "descriptor_set")
SUPPORTED_LANGUAGES=("go" "ruby" "csharp" "java" "python" "objc" "gogo" "php" "node" "web" "cpp" "descriptor_set" "nanopb")
EXTRA_INCLUDES=""
OUT_DIR=""
GO_SOURCE_RELATIVE=""
Expand Down Expand Up @@ -286,6 +286,9 @@ plugins=grpc+embedded\
GEN_STRING="$GEN_STRING --csharp_opt=$CSHARP_OPT"
fi
;;
"nanopb")
GEN_STRING="--nanopb_out=$OUT_DIR --plugin=protoc-gen-nanopb=/usr/local/lib/protoc-gen-nanopb/protoc-gen-nanopb"
;;
*)
GEN_STRING="--grpc_out=$OUT_DIR --${GEN_LANG}_out=$OUT_DIR --plugin=protoc-gen-grpc=`which grpc_${PLUGIN_LANG}_plugin`"
;;
Expand Down