187 lines
4.6 KiB
YAML
187 lines
4.6 KiB
YAML
version: '3.8'
|
|
|
|
# Docker Compose para teste local da infraestrutura BCards
|
|
# Simula o ambiente de produção com 2 servidores e load balancer
|
|
|
|
services:
|
|
# Aplicação Server 1
|
|
bcards-server1:
|
|
build: ./test-app
|
|
container_name: bcards-server1
|
|
environment:
|
|
- ASPNETCORE_ENVIRONMENT=Development
|
|
- SERVER_NAME=BCards Server 1
|
|
- SERVER_COLOR=#28a745
|
|
- ASPNETCORE_URLS=http://+:8080
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
depends_on:
|
|
- mongodb
|
|
|
|
# Aplicação Server 2
|
|
bcards-server2:
|
|
build: ./test-app
|
|
container_name: bcards-server2
|
|
environment:
|
|
- ASPNETCORE_ENVIRONMENT=Development
|
|
- SERVER_NAME=BCards Server 2
|
|
- SERVER_COLOR=#007bff
|
|
- ASPNETCORE_URLS=http://+:8080
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
depends_on:
|
|
- mongodb
|
|
|
|
# NGINX Load Balancer
|
|
nginx-lb:
|
|
image: nginx:alpine
|
|
container_name: bcards-nginx-lb
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx/nginx-test.conf:/etc/nginx/nginx.conf:ro
|
|
- ./nginx/logs:/var/log/nginx
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
depends_on:
|
|
- bcards-server1
|
|
- bcards-server2
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/nginx-health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 30s
|
|
|
|
# MongoDB para testes
|
|
mongodb:
|
|
image: mongo:7.0
|
|
container_name: bcards-mongodb
|
|
environment:
|
|
- MONGO_INITDB_ROOT_USERNAME=admin
|
|
- MONGO_INITDB_ROOT_PASSWORD=bcards123
|
|
- MONGO_INITDB_DATABASE=bcards
|
|
ports:
|
|
- "27017:27017"
|
|
volumes:
|
|
- mongodb_data:/data/db
|
|
- ./mongodb/init:/docker-entrypoint-initdb.d:ro
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 30s
|
|
|
|
# Redis para cache (opcional)
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: bcards-redis
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
command: redis-server /usr/local/etc/redis/redis.conf
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
# Fluentd para logs centralizados
|
|
fluentd:
|
|
image: fluent/fluentd:v1.16-debian-1
|
|
container_name: bcards-fluentd
|
|
volumes:
|
|
- ./nginx/fluentd/fluent-test.conf:/fluentd/etc/fluent.conf:ro
|
|
- ./nginx/logs:/var/log/nginx:ro
|
|
- fluentd_logs:/fluentd/log
|
|
ports:
|
|
- "24224:24224"
|
|
- "24224:24224/udp"
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
environment:
|
|
- FLUENTD_CONF=fluent.conf
|
|
|
|
# Prometheus para monitoramento (opcional)
|
|
prometheus:
|
|
image: prom/prometheus:latest
|
|
container_name: bcards-prometheus
|
|
ports:
|
|
- "9090:9090"
|
|
volumes:
|
|
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
- prometheus_data:/prometheus
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
- '--web.console.templates=/etc/prometheus/consoles'
|
|
- '--storage.tsdb.retention.time=200h'
|
|
- '--web.enable-lifecycle'
|
|
|
|
# Grafana para dashboards (opcional)
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
container_name: bcards-grafana
|
|
ports:
|
|
- "3000:3000"
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
|
|
networks:
|
|
- bcards-test-network
|
|
restart: unless-stopped
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=bcards123
|
|
- GF_USERS_ALLOW_SIGN_UP=false
|
|
depends_on:
|
|
- prometheus
|
|
|
|
networks:
|
|
bcards-test-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.20.0.0/16
|
|
|
|
volumes:
|
|
mongodb_data:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
fluentd_logs:
|
|
driver: local
|
|
prometheus_data:
|
|
driver: local
|
|
grafana_data:
|
|
driver: local |