From 11ba4797bee74bafd2b66e6c599bf595e1940a10 Mon Sep 17 00:00:00 2001 From: rubens21 Date: Tue, 12 Jul 2022 19:52:14 -0600 Subject: [PATCH 1/2] Adding support to Typescript Signed-off-by: rubens21 --- Dockerfile | 11 +++++++++-- README.md | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3bb3e92..32467e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ ARG ALPINE_VERSION=3.13 ARG GO_VERSION=1.14.15 -ARG GRPC_GATEWAY_VERSION=1.16.0 +ARG GRPC_GATEWAY_VERSION=1.16.0 ARG GRPC_JAVA_VERSION=1.35.0 ARG GRPC_CSHARP_VERSION=1.35.0 ARG GRPC_VERSION=1.35.0 ARG PROTOC_GEN_GO_VERSION=1.4.3 +ARG GRPC_WEB_VERSION=1.3.1 # v1.3.2, using the version directly does not work: "tar: invalid magic" ARG PROTOC_GEN_GOGO_VERSION=b03c65ea87cdc3521ede29f62fe3ce239267c1bc ARG PROTOC_GEN_LINT_VERSION=0.2.1 @@ -31,7 +32,7 @@ RUN apk add --no-cache automake ninja && \ ../.. && \ cmake --build . --target plugins && \ cmake --build . --target install && \ - DESTDIR=/out cmake --build . --target install + DESTDIR=/out cmake --build . --target install ARG GRPC_JAVA_VERSION RUN mkdir -p /grpc-java && \ @@ -49,6 +50,12 @@ RUN mkdir -p /grpc-java && \ rm -Rf /grpc-java && \ rm -Rf /grpc +ARG GRPC_WEB_VERSION +RUN curl -sSLO https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_VERSION}/protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64 && \ + mv protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64 /out/usr/bin/protoc-gen-grpc-web && \ + chmod +x /out/usr/bin/protoc-gen-grpc-web +# cp /out/usr/bin/protoc-gen-grpc-web /out/usr/bin/grpc_web_plugin + FROM protoc_base AS protoc_cs_builder ARG GRPC_CSHARP_VERSION diff --git a/README.md b/README.md index cb93ed7..f3f0394 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,15 @@ A lightweight `protoc` Docker image, published as `jaegertracing/protobuf` to [D - https://github.com/grpc-ecosystem/grpc-gateway - https://github.com/grpc/grpc - https://github.com/grpc/grpc-java +- https://github.com/grpc/grpc-web ## Supported languages - C# - C++ - Go - Java / JavaNano (Android) -- JavaScript +- JavaScript (pure) +- TypeScript (gRPC Web) - Objective-C - PHP - Python @@ -56,6 +58,7 @@ $ docker run --rm jaegertracing/protobuf --help --php_out=OUT_DIR Generate PHP source file. --python_out=OUT_DIR Generate Python source file. --ruby_out=OUT_DIR Generate Ruby source file. + --js_out=OUT_DIR --grpc-web_out=import_style=typescript,mode=grpcweb:OUT_DIR Generate Typescript source file. ``` Example for Java: @@ -64,6 +67,11 @@ docker run --rm -u $(id -u) -v${PWD}:${PWD} -w${PWD} jaegertracing/protobuf:late --java_out=${PWD} -I/usr/include/github.com/gogo/protobuf ${PWD}/model.proto ``` +Note about Typescript: +This is currently an experimental feature. +**Do not** use `import_style=typescript` for `--js_out` ([read plugin documentation](https://github.com/grpc/grpc-web#typescript-support)) + + CLI options: - `--proto_path`: The path where protoc should search for proto files - `--java_out` : Generate Java code in the provided path From 368eb9192f7e40e5f5eee87e09dd62d5d0f5d09a Mon Sep 17 00:00:00 2001 From: rubens21 Date: Tue, 12 Jul 2022 19:57:37 -0600 Subject: [PATCH 2/2] deleting commented out code Signed-off-by: rubens21 --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32467e6..90cbd31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,8 +54,6 @@ ARG GRPC_WEB_VERSION RUN curl -sSLO https://github.com/grpc/grpc-web/releases/download/${GRPC_WEB_VERSION}/protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64 && \ mv protoc-gen-grpc-web-${GRPC_WEB_VERSION}-linux-x86_64 /out/usr/bin/protoc-gen-grpc-web && \ chmod +x /out/usr/bin/protoc-gen-grpc-web -# cp /out/usr/bin/protoc-gen-grpc-web /out/usr/bin/grpc_web_plugin - FROM protoc_base AS protoc_cs_builder ARG GRPC_CSHARP_VERSION