Multi Container App for academic challenge.
The challenge implements a microservice voting app with 3 services Client, API server & Mongodb Service
The challenge is to cover the tools
- Docker
- Docker Compose
- Nginx
- API development with Nodejs
- Client development with React # Vite
- API documentation # Swaggify
Docker compose will build and start all containers & and allow them to communicate
$ docker-compose up
The client service is implemented with React Vite
Running the client service container as an independent container
Building the image
$ docker build . -t <docker-id>/<preferred-image-name> -f Dockerfile.dev
# docker build . -t patrickniyo/voting-app-client -f Dockerfile.dev
Running the container
$ docker run -p <host-port>:<exposed-container-port> <image-name>
# docker run 3000:3000 patrickniyo/voting-app-client
Running the development server
$ yarn dev
# npm run dev
The server is built with Nodejs and Express
Running the server container as an independent container
Building the image
$ docker build . -t <docker-id>/<preferred-image-name> -f Dockerfile.dev
# docker build . -t patrickniyo/voting-app-server -f Dockerfile.dev
Running the container
$ docker run -p <host-port>:<exposed-container-port> <image-name>
# docker run 5000:5000 patrickniyo/voting-app-server
Running the dev server
$ yarn start:dev
The nginx is used to set up a proxy server to benefit from some of it's features like Load Balancing .
Our nginx service is listening on port 80 of the host machine.
Our nginx server is accessible by http://localhost or http://localhost:80
The default requests like http://localhost are forwarded to the client service
It will be forwarding http://localhost:3000 requests to the client service and http://localhost:5000 to the backend api service
Thanks to @divinirakiza for a super tool to automate the API documentation with swagger.
The tool is Swaggiffy. Get it from npm
Swaggiffy is a zero config opensource tool for documenting your Node.js Express APIs and is built on top of Swagger. It is designed to be easy to use and simple, with the goal that anyone can read it.
Accessing the documentation