grpc-web/net/grpc/gateway/examples/echo
Stanley Cheung f92cedafbf Show how deadline can be set 2018-10-06 01:10:16 -07:00
..
commonjs-example Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
node-server Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
ts-example Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
BUILD.bazel Add bazel rule closure_grpc_web_library 2018-08-05 15:30:57 +02:00
Makefile Make all example clients consistent 2018-08-29 16:25:07 -07:00
README.md Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
echo.proto Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
echo_server.cc gRPC Sync 2018-05-01 16:30:37 -07:00
echo_service_impl.cc Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
echo_service_impl.h Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00
echoapp.js Experimental Typescript support 2018-08-24 15:34:01 -07:00
echotest.html Make all example clients consistent 2018-08-29 16:25:07 -07:00
envoy.yaml Show how deadline can be set 2018-10-06 01:10:16 -07:00
nginx.conf Minor fix to nginx dockerfile 2018-08-07 18:12:37 -07:00
nginx_simple.conf Make all example clients consistent 2018-08-29 16:25:07 -07:00
tutorial.md Add Node gRPC Server to Example 2018-10-02 13:28:56 -07:00

README.md

Build and Run an Echo example

This page will show you how to quickly build and run an end-to-end Echo example. The example has 3 key components:

  • Front-end JS client
  • Envoy proxy
  • gRPC backend server (written in Node)

Before you start

Before you start, ensure that you have the following installed exactly as per our pre-requisites:

  1. Protocol buffers
  2. gRPC
  3. Closure compiler

From the repo root directory:

Build pre-requisites

This step compiles gRPC and Protobuf, and serves as the base docker image for the subsequent docker images.

$ docker build -t grpcweb/prereqs \
  -f net/grpc/gateway/docker/prereqs/Dockerfile .

Run the gRPC Backend server

This compiles the gRPC backend server, written in Node, and listens on port 9090.

$ docker build -t grpcweb/node-server \
  -f net/grpc/gateway/docker/node_server/Dockerfile .
$ docker run -d -p 9090:9090 --name node-server grpcweb/node-server

Run the Envoy proxy

This step runs the Envoy proxy, and listens on port 8080. Any gRPC-Web browser requests will be forwarded to port 9090.

$ docker build -t grpcweb/envoy \
  -f net/grpc/gateway/docker/envoy/Dockerfile .
$ docker run -d -p 8080:8080 --link node-server:node-server grpcweb/envoy

Serve static JS/HTML contents

This steps compiles the front-end gRPC-Web client into a static .JS file, and we use a simple server to serve up the JS/HTML static contents.

$ docker build -t grpcweb/commonjs-client  \
  -f net/grpc/gateway/docker/commonjs_client/Dockerfile .
$ docker run -d -p 8081:8081 grpcweb/commonjs-client

Run the example from your browser

Finally, open a browser tab, and inspect

http://localhost:8081/echotest.html

What's next?

For more details about how you can run your own gRPC service and access it from the browser, please see this tutorial