| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- version: '3.8'
- services:
- # 后端服务
- backend:
- build:
- context: ../backend
- dockerfile: Dockerfile
- container_name: tolan-backend
- restart: unless-stopped
- ports:
- - "8765:8765"
- environment:
- - DEBUG=false
- - LOG_LEVEL=INFO
- - HOST=0.0.0.0
- - PORT=8765
- env_file:
- - ../backend/.env
- volumes:
- - ../backend/logs:/app/logs
- - /tmp/tolan:/tmp/tolan
- networks:
- - tolan-network
- healthcheck:
- test: ["CMD", "python", "-c", "import socket; socket.create_connection(('localhost', 8765), timeout=5)"]
- interval: 30s
- timeout: 10s
- retries: 3
- start_period: 40s
- depends_on:
- - redis
- logging:
- driver: "json-file"
- options:
- max-size: "10m"
- max-file: "3"
- # 前端服务 (Nginx)
- frontend:
- build:
- context: ../frontend
- dockerfile: Dockerfile.prod
- args:
- - REACT_APP_WS_URL=ws://localhost:8765
- - REACT_APP_ENV=production
- container_name: tolan-frontend
- restart: unless-stopped
- ports:
- - "80:80"
- - "443:443"
- volumes:
- - ./nginx.conf:/etc/nginx/nginx.conf:ro
- - ./ssl:/etc/ssl/certs:ro
- - nginx-logs:/var/log/nginx
- networks:
- - tolan-network
- depends_on:
- - backend
- logging:
- driver: "json-file"
- options:
- max-size: "10m"
- max-file: "3"
- # Redis 缓存服务 (可选)
- redis:
- image: redis:7-alpine
- container_name: tolan-redis
- restart: unless-stopped
- ports:
- - "6379:6379"
- volumes:
- - redis-data:/data
- networks:
- - tolan-network
- command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
- healthcheck:
- test: ["CMD", "redis-cli", "ping"]
- interval: 30s
- timeout: 10s
- retries: 3
- logging:
- driver: "json-file"
- options:
- max-size: "5m"
- max-file: "2"
- # 监控服务 (Prometheus)
- prometheus:
- image: prom/prometheus:latest
- container_name: tolan-prometheus
- restart: unless-stopped
- ports:
- - "9090:9090"
- volumes:
- - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- - prometheus-data:/prometheus
- networks:
- - tolan-network
- 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'
- logging:
- driver: "json-file"
- options:
- max-size: "5m"
- max-file: "2"
- # 日志聚合 (可选)
- filebeat:
- image: docker.elastic.co/beats/filebeat:8.8.0
- container_name: tolan-filebeat
- restart: unless-stopped
- user: root
- volumes:
- - ./filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- - /var/lib/docker/containers:/var/lib/docker/containers:ro
- - /var/run/docker.sock:/var/run/docker.sock:ro
- - filebeat-data:/usr/share/filebeat/data
- networks:
- - tolan-network
- depends_on:
- - backend
- - frontend
- logging:
- driver: "json-file"
- options:
- max-size: "5m"
- max-file: "2"
- networks:
- tolan-network:
- driver: bridge
- ipam:
- config:
- - subnet: 172.20.0.0/16
- volumes:
- redis-data:
- driver: local
- prometheus-data:
- driver: local
- nginx-logs:
- driver: local
- filebeat-data:
- driver: local
|