grpc-web/net/grpc/gateway/examples/echo
Eryu Xia 012b226922
Update async to `3.2.3` (fix vulnerability) (#1247)
2022-05-24 14:57:09 -07:00
..
commonjs-example Update references to version 1.3.1 (#1198) 2022-02-08 11:32:09 -08:00
node-server Update async to `3.2.3` (fix vulnerability) (#1247) 2022-05-24 14:57:09 -07:00
ts-example Update references to version 1.3.1 (#1198) 2022-02-08 11:32:09 -08:00
.gitignore Replace use of `third_party/closure-library` submodule 2021-09-01 18:17:14 -07:00
BUILD.bazel Clean up Javascript-related Bazel rules. (#1138) 2021-09-21 23:16:28 -07:00
Makefile Revamp Closure JsUnit tests runtime and optimize test/build flows. (#1137) 2021-09-21 15:27:21 -07:00
README.md Clean up Javascript-related Bazel rules. (#1138) 2021-09-21 23:16:28 -07:00
echo.proto Changes to deserializeBinary API; 2019-04-28 22:59:53 -07:00
echo_chat.js Add plumbing for ClosureJS echo-example 2020-11-20 12:51:47 -08: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 Internal code sync (#1139) 2021-09-22 16:53:00 -07:00
echotest.html Internal code sync (#1139) 2021-09-22 16:53:00 -07:00
envoy.yaml Fixing Envoy config yaml formatting (#1223) 2022-04-21 15:52:46 -07:00
package.json Internal code sync (#1140) 2021-09-28 10:48:20 -07:00
tutorial.md Fixing Envoy config yaml formatting (#1223) 2022-04-21 15:52:46 -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/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