thangchung / coffeeshop-on-nomad

The .NET coffeeshop application runs on Docker, Nomad and Consul Connect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coffeeshop-on-nomad

The .NET coffeeshop application runs on Nomad and Consul Connect

Services

No. Service Name URI
1 product-service http://localhost:5001 and http://localhost:15001
2 counter-service http://localhost:5002
3 barista-service http://localhost:5003
4 kitchen-service http://localhost:5004
5 reverse-proxy (local development only) http://localhost:5000
6 signalr-web (local development only) http://localhost:3000
7 datagen-app (local development only)

Get starting

Control plane UI:

Using client.http to explore the application!

devcontainer setup

F1 in vscode and choose Remote-Containers: Open Folder in Container..., then waiting until it build sucessful

# check linux version
> cat /etc/os-release
# build all images of application
> docker compose build 

Open a new tab

> cd local/
$ sudo chmod +x core-libs.sh start.sh
$ sudo ./core-libs.sh
# nomad cannot run on wsl2 image, then we need to work-around
$ sudo mkdir -p /lib/modules/$(uname -r)/
> echo '_/bridge.ko' | sudo tee -a /lib/modules/$(uname -r)/modules.builtin
# Start nomad and consul
> ./start.sh

Open another new tab

> cd nomad/jobs
> nomad job run traefik.nomad.hcl
> nomad job run postgresdb.nomad.hcl
> nomad job run rabbitmq.nomad.hcl
> nomad job run product-api.nomad.hcl
> nomad job run counter-api.nomad.hcl
> nomad job run barista-api.nomad.hcl
> nomad job run kitchen-api.nomad.hcl

Finally, you can play around using client.http to explore the application!

Clean up

> nomad job stop kitchen-api.nomad.hcl
> nomad job stop barista-api.nomad.hcl
> nomad job stop counter-api.nomad.hcl
> nomad job stop product-api.nomad.hcl
> nomad job stop rabbitmq.nomad.hcl
> nomad job stop postgresdb.nomad.hcl
> nomad job stop traefik.nomad.hcl

Troubleshooting

Couldn't run sebp/elk:latest on Docker (Windows 11 - WSL2 with Docker for Desktop integrated)

error: elasticsearch_1 | max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Jump into wsl2, then run command below

$ sudo sysctl -w vm.max_map_count=262144

Now, we can run docker-compose up again.

References

About

The .NET coffeeshop application runs on Docker, Nomad and Consul Connect

License:MIT License


Languages

Language:C# 84.7%Language:HCL 5.9%Language:Dockerfile 3.9%Language:Shell 3.3%Language:JavaScript 1.7%Language:TypeScript 0.2%Language:CSS 0.2%Language:HTML 0.1%