grpc-web/net/grpc/gateway/examples/echo
Stanley Cheung 0d747ec02c Update references to 1.2.0 2020-06-22 14:20:38 -07:00
..
commonjs-example Update references to 1.2.0 2020-06-22 14:20:38 -07:00
node-server Update to use @grpc/grpc-js node package, and update helloworld example 2020-06-11 15:37:46 -07:00
ts-example Update references to 1.2.0 2020-06-22 14:20:38 -07:00
BUILD.bazel Add experimental ES6 import style 2020-06-04 16:46:05 -07:00
Makefile WIP remove stream_body 2019-10-28 15:50:58 -07:00
README.md Fix some readme 2018-11-29 23:20:06 -08:00
echo.proto Changes to deserializeBinary API; 2019-04-28 22:59:53 -07:00
echo_server.cc gRPC Sync 2018-05-01 16:30:37 -07:00
echo_service_impl.cc internal sync 2018-10-14 17:37:16 -07:00
echo_service_impl.h internal sync 2018-10-14 17:37:16 -07:00
echoapp.js Refactor error handling in grpcwebclientbase 2020-06-21 22:18:52 -07:00
echotest.html Refactor error handling in grpcwebclientbase 2020-06-21 22:18:52 -07:00
envoy.yaml [fix] envoy deprecated fields 2020-06-21 22:02:33 -07:00
nginx.conf nginx example Expose-Headers add Grpc-Message,Grpc-Status 2019-10-21 09:47:42 -07:00
nginx_simple.conf Make all example clients consistent 2018-08-29 16:25:07 -07:00
tutorial.md Update references to 1.2.0 2020-06-22 14:20:38 -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)

From the repo root directory:

Build pre-requisites

This step downloads the necessary pre-requisites, and serves as the base docker image for the subsequent docker images.

$ docker build -t grpcweb/common \
  -f net/grpc/gateway/docker/common/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