Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Norihiro Hayashida committed Oct 22, 2021
1 parent 5c66bee commit 9aad568
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM alpine:edge

ARG PROTO_VERSION=3.18.1
ARG GRPCWEB_VERSION=1.3.0

LABEL version=${GRPCWEB_VERSION}
LABEL maintainer="nrhrhysd616 <[email protected]>"
LABEL description="protoc-gen-grpc-web"

# install protobuf and curl
RUN apk update && apk add --no-cache protobuf curl

# download Google defined proto files
RUN curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTO_VERSION}/protoc-${PROTO_VERSION}-linux-x86_64.zip -o /tmp/protoc.zip && \
unzip -qq /tmp/protoc.zip -d /tmp && \
cp -r /tmp/include /usr/local && \
rm -rf /tmp/*

# install protoc-gen-grpc-web
RUN curl -sSL https://github.com/grpc/grpc-web/releases/download/${GRPCWEB_VERSION}/protoc-gen-grpc-web-${GRPCWEB_VERSION}-linux-x86_64 -o /usr/local/bin/protoc-gen-grpc-web && \
chmod +x /usr/local/bin/protoc-gen-grpc-web

ADD scripts/entrypoint.sh /

VOLUME [ "/protos", "/out" ]

ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "--grpc-web_out=import_style=commonjs,mode=grpcwebtext" ]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
VERSION = 1.3.0

ifdef version
VERSION=${version}
endif

build:
docker build -t nrhrhysd616/protoc-gen-grpc-web:${VERSION} -t nrhrhysd616/protoc-gen-grpc-web:latest .
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# nrhrhysd616/protoc-gen-grpc-web
2 changes: 2 additions & 0 deletions examples/out/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
29 changes: 29 additions & 0 deletions examples/protos/user.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";

import "google/protobuf/descriptor.proto";
import "google/protobuf/empty.proto";

option java_multiple_files = true;
option java_package = "com.example.user";
option java_outer_classname = "UserProto";
option objc_class_prefix = "HLW";

service UserService {
rpc UpdateUser (UpdateUserRequest) returns (google.protobuf.Empty) {}
rpc DeleteUser (DeleteUserRequest) returns (google.protobuf.Empty) {}
}

message UpdateUserRequest {
string subject = 1;
string username = 3;
string email = 4;
string displayName = 5;
string phoneNumber = 6;
string picture = 7;
}

message DeleteUserRequest {
string subject = 1;
}


11 changes: 11 additions & 0 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

PROTOS_DIR=/protos
OUTPUT_DIR=/out

args=$1

exec protoc \
--proto_path=/usr/local/include:${PROTOS_DIR} \
${args}:${OUTPUT_DIR} \
${PROTOS_DIR}/*.proto

0 comments on commit 9aad568

Please sign in to comment.