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:
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 .
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
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
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
Finally, open a browser tab, and inspect
http://localhost:8081/echotest.html
For more details about how you can run your own gRPC service and access it from the browser, please see this tutorial