Starting a Microservices Project with NodeJS and Docker

Last year, I tried to build a starter project with Microservices pattern and DevOps culture. My source code is not perfect and there are many issue need to improve. However, I archived some goals, so I would like to share it to all of you. Please see my source code in Github here.

In this source code, I built two services, one for Frontend AngularJS and Bootstrap, one for Backend ExpressJS and Mongoose. All services in this project is dockerized and pushed to Docker Hub. You can read Dockerfile in each service for further details. To create a new service, you just create a new directory, writing source code for that service and update docker-compose.yml file. All Restful APIs should have documents, so I used Swagger Specs to write the document. It is really cool.

If you are many separate services, you can use my tool — swagger-combined to combine all Swagger Document to only one document.

All long task should be processed asynchronously in background. I know RabbitMQ and Kafka can help me. But in this case, I choose Redis and Kue Library to keep the project simple.

Run

The Orchestration of Project is written in docker-compose.yml file. So it is so easily to understand and run the project.

docker-compose up

Using Vagrant and Virtualbox

We also start from Virtual Machine layer with Vagrant.

vagrant up

After that, you can access the application via link: http://172.20.20.20

You can read Vagrantfile to understand what we need to prepare for VMs.

Monitor & Logs

This starter project also fully supports monitor by using Telegraf, InfluxDB, Grafana and Kapacitor. Supports centralizing Logs with fluentd, Kibana and Elasticsearch.

System Architecture

With the source code, we will have a system architecture as below

DevOps Microservices Starter Project

Thank you for your reading. Please give me comments if there is any issue need to improve or fix.