2023-08-08 10:56:22 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-08 10:56:22 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00
2023-08-05 22:10:48 +02:00

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 .env and 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.
  • ms is connected to the ms-network to 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 authorizations for example: https://localhost:4443/authorizations/health.
Description
A CLI to create a local environment to deploy and use dockerized microservices.
Readme 48 KiB
Languages
Go 94.9%
Makefile 2.2%
Dockerfile 1.5%
Shell 1.4%