This setup uses Docker Compose to run a set of microservices including RabbitMQ, PostgreSQL databases for main and mailer services, Prometheus for monitoring, and Grafana for data visualization. Additionally, two application services, main
and mailer
, are configured to communicate with these dependencies.
- Docker and Docker Compose installed on your system
- RabbitMQ: Acts as the message broker.
- Postgres Databases: Separate instances for
main
andmailer
services. - Main Service: Primary application service.
- Mailer Service: Handles email functionality.
- Prometheus: For monitoring RabbitMQ metrics.
- Grafana: For visualizing metrics.
To start all services, navigate to the directory containing docker-compose.yml
and run:
docker-compose up -d
This command will build and run all containers in the background.
To check the logs for any specific service, use:
docker-compose logs -f <service_name>
Replace <service_name>
with any of the following:
rabbitmq
postgres_main
postgres_mailer
main
mailer
prometheus
grafana
- RabbitMQ Management Console: http://localhost:15672
- Default login:
guest
, password:guest
- Default login:
- Prometheus: http://localhost:9090
- Grafana: http://localhost:8181
- Default login:
admin
, password:admin
- Default login:
- Main Service: http://localhost:3000
- Mailer Service: http://localhost:3001
To run tests for the mailer
service, execute the following command:
docker-compose run mailer npm run test
This command will run the tests inside the mailer
service container. Replace npm run test
with the specific test command if it differs in your package.json
setup.
To stop and remove all services, use:
docker-compose down
This will stop the containers and remove them, along with any associated networks created by Docker Compose.
- Environment Variables: Customize
.env
or add secure environment variables as required. - Volumes: Persistent storage is configured for PostgreSQL databases to retain data between container restarts.
This completes the setup and usage instructions for the microservices environment.