5.1 KiB
5.1 KiB
localenv
This project aims to deploy a microservices environment on local. It will connect and deploy all the microservices and their dependencies (postgres, rabbitmq, etc...).
Requirements
- Linux (feel sorry for macos users 😭)
- dockerd >= 20.10.23
- sysbox
- go >= 1.20
- dockerd ubuntu image
make docker-swarm
- nginx with embedded microservice conf
make docker-nginx
Run
- Create a
.envand feed values for your needs
cp .env.example .env
- Launch/install the local environment
make start
- Stop it
make stop
- Purge (remove the environment and all the data)
Be careful ! All the local data will be removed !
make purge
- Enable watcher
The watcher is used to auto deploy a microservice on the Swarm when the microservice is built.
make start-watch
How it works ?
localenv uses a container with Docker Swarm to deploy microservices as Docker services. It is completely isolated and does not pollute your docker environment.
local dockerd
┌─────────────────────────────────────────────────────────────────────┐
│ docker swarm (DinD) │
│ ┌───────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ ┌────────────┐ ┌───────────────────────────────┐ │ │
│ │ │rabbitmq │ │ │ │ │
│ │ │ │ │ ┌─────────┐ ┌─────────┐ │ │ │
│ │ │ ├────────┼─┤ms │ │postgres │ │ │ │
│ │ │ │ │ │ ├──────┤ │ │ │ │
│ │ └──┬─────────┘ │ │ │ │ │ │ │ │
│ │ │:15672 │ │ │ │ │ │ │ │
│ │ │ │ └─┬───────┘ └────┬────┘ │ │ │
│ │ │ │ │ │ │ │ │
│ │ │ ┌──────────┐ │ │ ┌───────────────┴─────┐ │ │ │
│ │ │ │nginx │ │ │ │persistent storage │ │ │ │
│ │ │ │ ├───┼───┘ └─────────────────────┘ │ │ │
│ │ │ │ │ │ │ │ │
│ │ │ └──┬───────┘ │ db-network│ │ │
│ │ │ │:4443 └───────────────────────────────┘ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │:4523 ms-network│ │
│ └────┼──────┼───────────────────────────────┼───────────────────┘ │
│ │ │ │ │
└───────┼──────┼───────────────────────────────┼──────────────────────┘
│ │ │
│ │ │
▼ ▼ ▼
The scheme above explains how the localenv is deployed.
- A container, running with the sysbox runtime, as a Docker Swarm.
- The Swarm dockerd is available from the outside to interact easily with it.
msis connected to thems-networkto communicate with the others microservices (DNS resolution).- A Postgres DB can be connected to a microservice and be isolated in a network. For simplicity, if a microservice needs a database, a new database is deployed.
- RabbitMQ is common between all microservices. The management UI is available and accessible at http://localhost:15672.
- nginx as a reverse proxy. To access
authorizationsfor example: https://localhost:4443/authorizations/health.