Skip to content

Building a full stack voting app challenge. Covering mult-containers with docker, docker-compose, nginx

Notifications You must be signed in to change notification settings

PatrickNiyogitare28/voting-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voting App

Multi Container App for academic challenge.

The challenge implements a microservice voting app with 3 services Client, API server & Mongodb Service

Scope of the challenge

The challenge is to cover the tools

  • Docker
  • Docker Compose
  • Nginx
  • API development with Nodejs
  • Client development with React # Vite
  • API documentation # Swaggify

Running the app with docker compose

Docker compose will build and start all containers & and allow them to communicate

$ docker-compose up

Client

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

Server

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

Nginx

The nginx is used to set up a proxy server to benefit from some of it's features like Load Balancing .

Image

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

API Documentations

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

http://localhost:5000/api-docs

Author

Patrick Niyogitare

About

Building a full stack voting app challenge. Covering mult-containers with docker, docker-compose, nginx

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published