version: '3.8' services: # PostgreSQL 数据库 postgres: image: postgres:15-alpine container_name: tyapi-postgres environment: POSTGRES_DB: tyapi_dev POSTGRES_USER: postgres POSTGRES_PASSWORD: Pg9mX4kL8nW2rT5y POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C" ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data - ./scripts/init.sql:/docker-entrypoint-initdb.d/init.sql networks: - tyapi-network healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 # Redis 缓存 redis: image: redis:7-alpine container_name: tyapi-redis ports: - "6379:6379" volumes: - redis_data:/data - ./deployments/docker/redis.conf:/usr/local/etc/redis/redis.conf command: redis-server /usr/local/etc/redis/redis.conf networks: - tyapi-network healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 5 # Jaeger 链路追踪 jaeger: image: jaegertracing/all-in-one:latest container_name: tyapi-jaeger ports: - "16686:16686" # Jaeger UI - "14268:14268" # Jaeger HTTP collector environment: COLLECTOR_OTLP_ENABLED: true networks: - tyapi-network # Prometheus 监控 prometheus: image: prom/prometheus:latest container_name: tyapi-prometheus ports: - "9090:9090" volumes: - ./deployments/docker/prometheus.yml:/etc/prometheus/prometheus.yml - prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' networks: - tyapi-network # Grafana 仪表盘 grafana: image: grafana/grafana:latest container_name: tyapi-grafana ports: - "3000:3000" environment: GF_SECURITY_ADMIN_PASSWORD: Gf7nB3xM9cV6pQ2w volumes: - grafana_data:/var/lib/grafana - ./deployments/docker/grafana/provisioning:/etc/grafana/provisioning networks: - tyapi-network # MinIO 对象存储 (S3兼容) minio: image: minio/minio:latest container_name: tyapi-minio ports: - "9000:9000" - "9001:9001" environment: MINIO_ROOT_USER: minioadmin MINIO_ROOT_PASSWORD: Mn5oH8yK3bR7vX1z volumes: - minio_data:/data command: server /data --console-address ":9001" networks: - tyapi-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3 # Mailhog 邮件测试服务 mailhog: image: mailhog/mailhog:latest container_name: tyapi-mailhog ports: - "1025:1025" # SMTP - "8025:8025" # Web UI networks: - tyapi-network # pgAdmin 数据库管理 pgadmin: image: dpage/pgadmin4:latest container_name: tyapi-pgadmin environment: PGADMIN_DEFAULT_EMAIL: admin@tyapi.com PGADMIN_DEFAULT_PASSWORD: Pa4dG9wF2sL6tN8u PGADMIN_CONFIG_SERVER_MODE: 'False' ports: - "5050:80" volumes: - pgadmin_data:/var/lib/pgadmin networks: - tyapi-network depends_on: - postgres volumes: postgres_data: driver: local redis_data: driver: local prometheus_data: driver: local grafana_data: driver: local minio_data: driver: local pgadmin_data: driver: local networks: tyapi-network: driver: bridge