Files
EventHubBack/docker/docker-compose.yml

155 lines
5.1 KiB
YAML

# docker/docker-compose.yml
services:
# ================== Балансировщик нагрузки (HTTPS/WSS) ==================
traefik:
image: traefik:latest
user: "0:1001" # группа docker на хосте (подберите под свою систему, см. ls -la /var/run/docker.sock)
command:
- "--api.insecure=true" # дашборд (можно удалить в production)
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.file.filename=/etc/traefik/dynamic_conf.yml" # самоподписанный сертификат, редирект и failover
- "--entrypoints.web.address=:80" # HTTP (для редиректа)
- "--entrypoints.websecure.address=:443" # HTTPS/WSS
# Метрики Prometheus
- "--metrics.prometheus=true"
- "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
- "--metrics.prometheus.addEntryPointsLabels=true"
- "--metrics.prometheus.addServicesLabels=true"
ports:
- "80:80"
- "443:443"
# порт дашборда (опционально)
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik/certs:/etc/traefik/certs:ro" # самоподписанный сертификат
- "./traefik/dynamic_conf.yml:/etc/traefik/dynamic_conf.yml:ro"
networks:
- eventhub-net
restart: unless-stopped
# ================== Сервис-заглушка для Failover ==================
fallback:
build:
context: ./fallback
dockerfile: Dockerfile
networks:
- eventhub-net
restart: unless-stopped
# ================== Кластер EventHub (3 ноды) ==================
eventhub-node1:
build:
context: ..
dockerfile: docker/Dockerfile
hostname: eventhub-node1.local
environment:
- NODE_NAME=eventhub-node1@eventhub-node1.local
- RELEASE_COOKIE=${RELEASE_COOKIE}
- JWT_SECRET=${JWT_SECRET}
- JOIN_NODES=eventhub-node1@eventhub-node1.local,eventhub-node2@eventhub-node2.local,eventhub-node3@eventhub-node3.local
networks:
- eventhub-net
volumes:
- eventhub-node1-data:/app/data
labels:
- "traefik.enable=true"
restart: unless-stopped
eventhub-node2:
build:
context: ..
dockerfile: docker/Dockerfile
hostname: eventhub-node2.local
environment:
- NODE_NAME=eventhub-node2@eventhub-node2.local
- RELEASE_COOKIE=${RELEASE_COOKIE}
- JWT_SECRET=${JWT_SECRET}
- JOIN_NODES=eventhub-node1@eventhub-node1.local,eventhub-node2@eventhub-node2.local,eventhub-node3@eventhub-node3.local
networks:
- eventhub-net
volumes:
- eventhub-node2-data:/app/data
labels:
- "traefik.enable=true"
restart: unless-stopped
eventhub-node3:
build:
context: ..
dockerfile: docker/Dockerfile
hostname: eventhub-node3.local
environment:
- NODE_NAME=eventhub-node3@eventhub-node3.local
- RELEASE_COOKIE=${RELEASE_COOKIE}
- JWT_SECRET=${JWT_SECRET}
- JOIN_NODES=eventhub-node1@eventhub-node1.local,eventhub-node2@eventhub-node2.local,eventhub-node3@eventhub-node3.local
networks:
- eventhub-net
volumes:
- eventhub-node3-data:/app/data
labels:
- "traefik.enable=true"
restart: unless-stopped
# ================== Мониторинг ==================
prometheus:
image: prom/prometheus:latest
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- '--storage.tsdb.retention.time=30d'
- '--storage.tsdb.retention.size=15GB'
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
networks:
- eventhub-net
ports:
- "9090:9090"
restart: unless-stopped
grafana:
image: grafana/grafana:latest
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_SECURITY_DISABLE_INITIAL_ADMIN_PASSWORD_CHANGE=false
- GF_USERS_ALLOW_SIGN_UP=false
- GF_AUTH_ANONYMOUS_ENABLED=false
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/etc/grafana/dashboards
- grafana-data:/var/lib/grafana
networks:
- eventhub-net
ports:
- "3000:3000"
restart: unless-stopped
# ================== Инструмент отладки ==================
observer_web:
build:
context: ..
dockerfile: docker/ObserverWeb.Dockerfile
environment:
- RELEASE_COOKIE=${RELEASE_COOKIE}
networks:
- eventhub-net
ports:
- "4000:4000"
restart: unless-stopped
# ================== Сети и тома ==================
networks:
eventhub-net:
driver: bridge
volumes:
eventhub-node1-data:
eventhub-node2-data:
eventhub-node3-data:
prometheus-data:
grafana-data: