A simple project demonstrating how both a Go and Java back end can power the same Vue.js front end using gRPC.
- The server consists either of a Java or Go Lang project.
- The Java project uses the Spring Boot framework with Maven for dependency management.
- TODO: Go Lang project...
- The client is written in TypeScript and uses the VueJS framework. It also uses Vuetify and the official gRPC-Web library.
- The Envoy Proxy is used to translate requests and responses between the browser and the gRPC server. Check out the state of gRPC in the browser.
- TLS/SSL is used to allow HTTP2 connections between the browser and Envoy. This is to circumvent browser connection limitations. More on this here.
The root of the project contains the shared API and client code. Checkout the relevant server branch in your language of choice.
master -> dev-stable [-> dev] -> go-dev-stable [-> go-dev]
-> java-dev-stable [-> java-dev]
- Install Docker on your local machine.
- Go to the releases page of Protobuf.
- Select the latest release version.
- Scroll down to
Assets
and download the applicable file (e.g., for Windowsprotoc-3.8.0-rc-1-win64.zip
). - Extract the contents and add to your path (e.g., for Windows, simply add the
protoc.exe
to your path).
- Go to the releases page of gRPC-Web.
- Select the latest release version.
- Scroll down to
Assets
and download the applicable file (e.g., for Windowsprotoc-gen-grpc-web-1.0.4-windows-x86_64.exe
). - Extract the
protoc-gen-grpc-web
file a directory and it to your path (e.g., for Windows add theprotoc-gen-grpc-web.exe
file to your path).
- Checkout the
java-dev-stable
branch. - Execute
mvn clean install
in the root directory to build and compile the project.- This will generate all the necessary Protocol Buffer files for the server and client.
- This will execute the
create-cert.sh
script, generating all necessary keys and certificates for the Vue development server and the Envoy Proxy.
- To securely serve the Vue files on the Spring Boot server for production, execute the
create-cert-java.sh
script. - Simply run the
ChatApplication.java
as a normal Java application. This will start the server. See theresources/application.properties
file for server configuration details.
- Checkout the
go-dev-stable
branch. - TODO: Run gradle install/build script that builds files, generates protos, runs the create-cert.sh script, etc.
- To serve the Vue files on the Go static file server for production, execute the
create-cert-go.sh
script. - TODO: Run the Go server somehow...
- From the root directory, run the
create-ca-cert.sh
script to generate the Certificate Authority. - In the same directory, run the
create-cert.sh
script. See theenvoy/README.md
file for more details.- Note: This step should be unnecessary for the Java project if the
mvn clean install
command was used.
- Note: This step should be unnecessary for the Java project if the
- Run
docker-compose up
from the root directory to start the Envoy proxy.- Note: Remember to remove the Docker image after generating new certificates!
- Run
npm install
and thennpm run proto
.- Note: This step is unnecessary after running the
mvn clean install
command for the Java server.
- Note: This step is unnecessary after running the
- Run
npm run serve
to start the development server on https://localhost:443.
- Install Docker on the Linux host machine. Follow the relevant instructions here:
- Install Docker Compose by running the following two commands (see more on Install Docker Compose):
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
- From within the project root directory, run the
mvn clean install -U
command to build the Java project. - Copy the generated
.jar
file to a directory on the host machine. - Run the Java Server with
java -jar server-<version>.jar
to start the server.
- TODO: Figure out how to run the Go server on production.
- Modify the
envoy.yaml
file for production. Change the following:- Change the
domains
value to the host machine IP address (or*
to allow all domains). - Change the
cors
allow_origin
to the correct domain (e.g., https://example.com). You can also use*
to allow all origins. - Change the
hosts
socket address
to the machine IP address.
- Change the
- Copy the
envoy
directory to a directory on the host machine. - Copy the
docker-compose.yml
file one level up from theenvoy
directory copied in the previous step. - Run
docker-compose up
to build and deploy the Docker image.- NOTE: Remember to remove the docker image before running the
docker-compose
command if any changes to Envoy or the certificates were made.
- NOTE: Remember to remove the docker image before running the
- If using a custom CA, add the relevant
ca.crt
file to the Trusted Root Certificate Authorities on your local machine. - The client should now be running on
https://<host-machine-ip>
.