Fully managed microservices starter using NestJS, Kong API gateway, RabbitMQ, Redis Queues, Firebase Cloud Notifications.
- RabbitMQ - https://www.rabbitmq.com/
- Redis - https://redis.io/
- Grafana - https://grafana.com/
- MognoDB - https://www.mongodb.com/
- PostgreSQL - https://www.postgresql.org/
- Kong - https://konghq.com/
- Loki - https://grafana.com/oss/loki/
- Fluent-Bit - https://fluentbit.io/
- use
git submodule update --init --recursive
command to update/fetch submodules. - copy env variables from each submodule repo from
example.env
file. - To explore APIs collection here is the link of postman collection
- you can start local environment by running
docker-compose.test.yml
file. file only contains service dependencies so that you don't need to start each service seperatly on your own. but keep in mind that if you're running any of the service in local then you need to change.env
and replace all docker host variables tolocalhost
. otherwise it will throw an error. - you can start all services together using
docker-compose up
. keep in mind that you will have to change environment variables to docker host variables as we're running all the services in docker and docker can't find local network in the container. kong.yml
file will be used for routing of services. after creating new service, define that service inkong.yml
first.- The development server will start on port
8000
.
To see the logs on Grafana dashboard, you can follow YouTube video or below steps.
- Open the browser and go to http://localhost:3000, use default values admin and admin for username and password.
- Now, go to http://localhost:3000/datasources and select Loki from Logging and document databases section.
- Enter http://loki:3100 in URL under HTTP section. We can do this because we are running Loki and Grafana in the same network.
- loki else you have to enter host IP address and port here, click on Save and Test button from the bottom of the page.
- Now, go to 3rd tab Explore from the left sidebar or http://localhost:3000/explore
- first start all deps from
docker-compose.test.yml
docker-compose -f docker-compose.test.yml up
- to start any service in development mode
npm start
- then you can access service endpoint directly using localhost.
- build docker-compose images
docker-compose up
- and then you can access services from kong api gateway on port
8000
.
Deploy services to dockerhub.
sh deploy.sh
Notes:
- you can also use this script to deploy services to ECR. change
deploy.sh
script accordingly. - Use
.prod.env
file for deployment of the services. - you can follow deployment process as below
- Docker compose context method (Cloud Formation with compose CLI). follow this (Blog)[https://www.docker.com/blog/docker-compose-from-local-to-amazon-ecs/]
- Use ECS CLI method. follow this (Blog)[https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-fargate.html]
- Use
hostname
of service to connect service internally in local docker environment. - for rebuild all services use command
docker-compose up --build
. - Use
docker-compose.prod.yml
for deployment if you're followingcompose cli
deployment strategy.