336 lines
8.9 KiB
YAML
336 lines
8.9 KiB
YAML
name: booksync
|
|
volumes:
|
|
prometheus-data:
|
|
grafana-data:
|
|
postgres-data:
|
|
pgadmin-data:
|
|
flower-data:
|
|
|
|
networks:
|
|
booksync-front:
|
|
booksync-back:
|
|
|
|
services:
|
|
|
|
####################################
|
|
# Tableau de bord Plotly Dash : démonstration autonome
|
|
#
|
|
dash:
|
|
image: booksync-dash:latest
|
|
hostname: booksync-dash
|
|
ports:
|
|
- "8050:8050"
|
|
networks:
|
|
- booksync-front
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- python
|
|
- -c
|
|
- "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8050/health', timeout=3)"
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
####################################
|
|
# Prometheus enregistre des métriques en temps réel dans une base de données de séries temporelles.
|
|
# Pour enregistrer les métrique, Prometheus se base sur le contenu de point d'entrée exposé à l'aide du protocole HTTP (/metrics).
|
|
# Son rôle est de collecter les métriques de chaque service.
|
|
#
|
|
prometheus:
|
|
image: prom/prometheus:latest
|
|
hostname: prometheus
|
|
container_name: prometheus
|
|
volumes:
|
|
- prometheus-data:/prometheus
|
|
- ./_docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
- ./_docker/alertmanager/alert.rules/alerts.rules.yml:/alertmanager/alert.rules/alerts.rules.yml
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--storage.tsdb.retention.time=365d'
|
|
ports:
|
|
- 9090:9090
|
|
networks:
|
|
- booksync-back
|
|
restart: always
|
|
|
|
####################################
|
|
# Exporte les métriques de la machine
|
|
#
|
|
node_exporter:
|
|
image: prom/node-exporter:latest
|
|
hostname: node-exporter
|
|
container_name: node-exporter
|
|
ports:
|
|
- 9100:9100
|
|
networks:
|
|
- booksync-back
|
|
restart: always
|
|
|
|
####################################
|
|
# Gestionnaire d'alertes
|
|
#
|
|
alertmanager:
|
|
image: prom/alertmanager:latest
|
|
hostname: alertmanager
|
|
container_name: alertmanager
|
|
volumes:
|
|
- ./_docker/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
|
|
- ./_docker/alertmanager/templates/default.tmpl:/etc/alertmanager/templates/default.tmpl
|
|
command:
|
|
- '--config.file=/etc/alertmanager/alertmanager.yml'
|
|
ports:
|
|
- 9093:9093
|
|
networks:
|
|
- booksync-back
|
|
restart: always
|
|
|
|
####################################
|
|
# Permet la visualisation de données. Il permet de réaliser des tableaux de bord et des graphiques depuis plusieurs sources dont des bases de données temporelles
|
|
# Monitoring des métriques
|
|
#
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
hostname: grafana
|
|
container_name: grafana
|
|
environment:
|
|
- GF_PATHS_CONFIG=/etc/grafana/grafana.ini
|
|
volumes:
|
|
- grafana-data:/var/lib/grafana
|
|
- ./_docker/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
|
|
- ./_docker/grafana/dashboards.yml:/etc/grafana/provisioning/dashboards/dashboards.yml
|
|
- ./_docker/grafana/grafana.ini:/etc/grafana/grafana.ini
|
|
- ./_docker/grafana/dashboards:/var/lib/grafana/dashboards
|
|
ports:
|
|
- 3000:3000
|
|
networks:
|
|
- booksync-back
|
|
depends_on:
|
|
- prometheus
|
|
restart: always
|
|
|
|
####################################
|
|
# Base de donnée relationnelle
|
|
#
|
|
postgres:
|
|
image: pgvector/pgvector:pg17
|
|
hostname: postgres
|
|
container_name: postgres
|
|
environment:
|
|
POSTGRES_DB: postgres
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
volumes:
|
|
- postgres-data:/var/lib/postgresql/data
|
|
- ./_docker/postgres/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
|
|
healthcheck:
|
|
test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "postgres" ]
|
|
timeout: 45s
|
|
interval: 10s
|
|
retries: 10
|
|
ports:
|
|
- 5432:5432
|
|
networks:
|
|
- booksync-back
|
|
restart: unless-stopped
|
|
|
|
####################################
|
|
# Exporte des métriques de la base de données
|
|
#
|
|
postgres-exporter:
|
|
image: bitnami/postgres-exporter:latest
|
|
hostname: postgres-exporter
|
|
container_name: postgres-exporter
|
|
environment:
|
|
DATA_SOURCE_URI: postgres:5432/postgres?sslmode=disable
|
|
DATA_SOURCE_USER: postgres
|
|
DATA_SOURCE_PASS: postgres
|
|
ports:
|
|
- 9187:9187
|
|
networks:
|
|
- booksync-back
|
|
depends_on:
|
|
- postgres
|
|
restart: always
|
|
|
|
####################################
|
|
# Administration de la base de donnée relationnelle
|
|
#
|
|
pgadmin:
|
|
image: dpage/pgadmin4:latest
|
|
hostname: pgadmin
|
|
container_name: pgadmin
|
|
environment:
|
|
PGADMIN_DEFAULT_EMAIL: admin@domain.com
|
|
PGADMIN_DEFAULT_PASSWORD: admin
|
|
PGADMIN_CONFIG_SERVER_MODE: 'False'
|
|
volumes:
|
|
- pgadmin-data:/var/lib/pgadmin
|
|
ports:
|
|
- 5050:80
|
|
networks:
|
|
- booksync-back
|
|
depends_on:
|
|
- postgres
|
|
restart: unless-stopped
|
|
|
|
####################################
|
|
# Agent de messages pour celery (broker), il est utilisé comme middleware entre des producers et des workers
|
|
# Exporte ses propres métriques
|
|
#
|
|
rabbitmq:
|
|
image: rabbitmq:3-management
|
|
hostname: rabbitmq
|
|
container_name: rabbitmq
|
|
healthcheck:
|
|
test: ["CMD", "rabbitmq-diagnostics", "-q", "check_port_connectivity"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 15s
|
|
ports:
|
|
- 5672:5672
|
|
- 15672:15672
|
|
networks:
|
|
- booksync-back
|
|
restart: unless-stopped
|
|
|
|
####################################
|
|
# Mémoire cache pour celery (result backend), il est utilisé comme middleware entre des producers et des workers
|
|
#
|
|
redis:
|
|
image: redis:latest
|
|
hostname: redis
|
|
container_name: redis
|
|
environment:
|
|
- ALLOW_EMPTY_PASSWORD=yes
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 5s
|
|
ports:
|
|
- 6379:6379
|
|
networks:
|
|
- booksync-back
|
|
restart: unless-stopped
|
|
|
|
####################################
|
|
# Exporteur des métriques redis
|
|
#
|
|
redis-exporter:
|
|
image: bitnami/redis-exporter:latest
|
|
hostname: redis-exporter
|
|
container_name: redis-exporter
|
|
environment:
|
|
REDIS_ADDR: redis://redis:6379
|
|
ports:
|
|
- 9121:9121
|
|
networks:
|
|
- booksync-back
|
|
depends_on:
|
|
- redis
|
|
restart: always
|
|
|
|
####################################
|
|
# Exporteur des métriques celery & monitoring des workers
|
|
#
|
|
flower:
|
|
image: mher/flower:latest
|
|
hostname: flower
|
|
container_name: flower
|
|
environment:
|
|
CELERY_BROKER_URL: "pyamqp://guest:guest@rabbitmq:5672//"
|
|
CELERY_RESULT_BACKEND: "redis://redis:6379/0"
|
|
FLOWER_BROKER_API: "http://guest:guest@rabbitmq:15672/api/"
|
|
FLOWER_PORT: "5555"
|
|
FLOWER_PERSISTENT: "true"
|
|
ports:
|
|
- 5555:5555
|
|
networks:
|
|
- booksync-back
|
|
depends_on:
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: always
|
|
|
|
####################################
|
|
# API REST basée sur FastAPI
|
|
# Contiens :
|
|
# - des requêtes à la base de donnée relationnelle
|
|
# Producteur de tâches celery
|
|
#
|
|
api:
|
|
image: booksync-api:latest
|
|
hostname: booksync-api
|
|
command: [
|
|
"uvicorn",
|
|
"api:app",
|
|
"--host",
|
|
"0.0.0.0",
|
|
"--port",
|
|
"5001",
|
|
"--workers",
|
|
"2",
|
|
"--log-level",
|
|
"info"]
|
|
environment:
|
|
POSTGRES_DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres/postgres
|
|
CELERY_BROKER_URL: pyamqp://guest:guest@rabbitmq:5672//
|
|
CELERY_RESULT_BACKEND_URL: redis://redis:6379/0
|
|
MANGACOLLEC_ID: 38fee110b53a75af6cc72f6fb66fa504fc6241e566788f4b2f5b21c25ba2fefb
|
|
MANGACOLLEC_SECRET: 060658630f7d199c19ab1cf34ed4e50935c748267e318a24e048d6ab45871da2
|
|
ports:
|
|
- 5001:5001
|
|
networks:
|
|
- booksync-back
|
|
- booksync-front
|
|
depends_on:
|
|
- rabbitmq
|
|
- redis
|
|
restart: always
|
|
|
|
####################################
|
|
# Worker basé sur celery
|
|
# 5 Replicas sont créer
|
|
#
|
|
worker:
|
|
image: booksync-worker:latest
|
|
deploy:
|
|
replicas: 5
|
|
command: [
|
|
"celery",
|
|
"-A",
|
|
"tasks:app",
|
|
"worker",
|
|
"--pool",
|
|
"prefork",
|
|
"-Q",
|
|
"booksync-worker",
|
|
"--concurrency=3",
|
|
"-n",
|
|
"booksync-worker@%h",
|
|
"--loglevel",
|
|
"INFO"]
|
|
environment:
|
|
CELERY_BROKER_URL: pyamqp://guest:guest@rabbitmq:5672//
|
|
CELERY_RESULT_BACKEND_URL: redis://redis:6379/0
|
|
MANGACOLLEC_ID: 38fee110b53a75af6cc72f6fb66fa504fc6241e566788f4b2f5b21c25ba2fefb
|
|
MANGACOLLEC_SECRET: 060658630f7d199c19ab1cf34ed4e50935c748267e318a24e048d6ab45871da2
|
|
networks:
|
|
- booksync-back
|
|
depends_on:
|
|
flower:
|
|
condition: service_started
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: always
|