2025-06-30 19:21:56 +08:00
|
|
|
services:
|
2025-07-02 16:17:59 +08:00
|
|
|
# PostgreSQL 数据库
|
|
|
|
|
postgres:
|
|
|
|
|
image: postgres:16.9
|
|
|
|
|
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:8.0.2
|
|
|
|
|
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
|
2025-06-30 19:21:56 +08:00
|
|
|
|
2025-07-02 16:17:59 +08:00
|
|
|
# Jaeger 链路追踪
|
|
|
|
|
jaeger:
|
|
|
|
|
image: jaegertracing/all-in-one:1.70.0
|
|
|
|
|
container_name: tyapi-jaeger
|
|
|
|
|
ports:
|
|
|
|
|
- "16686:16686" # Jaeger UI
|
|
|
|
|
- "14268:14268" # Jaeger HTTP collector (传统)
|
|
|
|
|
- "14250:14250" # Jaeger gRPC collector
|
|
|
|
|
- "4317:4317" # OTLP gRPC receiver
|
|
|
|
|
- "4318:4318" # OTLP HTTP receiver
|
|
|
|
|
environment:
|
|
|
|
|
# 启用OTLP接收器
|
|
|
|
|
COLLECTOR_OTLP_ENABLED: true
|
|
|
|
|
# 配置内存存储
|
|
|
|
|
SPAN_STORAGE_TYPE: memory
|
|
|
|
|
# 设置日志级别
|
|
|
|
|
LOG_LEVEL: info
|
|
|
|
|
# 配置采样策略
|
|
|
|
|
SAMPLING_STRATEGIES_FILE: /etc/jaeger/sampling_strategies.json
|
|
|
|
|
# 内存存储配置
|
|
|
|
|
MEMORY_MAX_TRACES: 50000
|
|
|
|
|
# 查询服务配置
|
|
|
|
|
QUERY_MAX_CLOCK_SKEW_ADJUSTMENT: 0
|
|
|
|
|
# 收集器配置
|
|
|
|
|
COLLECTOR_QUEUE_SIZE: 2000
|
|
|
|
|
COLLECTOR_NUM_WORKERS: 50
|
|
|
|
|
# gRPC服务器配置
|
|
|
|
|
COLLECTOR_GRPC_SERVER_MAX_RECEIVE_MESSAGE_LENGTH: 4194304
|
|
|
|
|
COLLECTOR_GRPC_SERVER_MAX_CONNECTION_AGE: 60s
|
|
|
|
|
# HTTP服务器配置
|
|
|
|
|
COLLECTOR_HTTP_SERVER_HOST_PORT: :14268
|
|
|
|
|
# UI配置
|
|
|
|
|
QUERY_UI_CONFIG: /etc/jaeger/ui-config.json
|
|
|
|
|
volumes:
|
|
|
|
|
- ./deployments/docker/jaeger-sampling.json:/etc/jaeger/sampling_strategies.json
|
|
|
|
|
- ./deployments/docker/jaeger-ui-config.json:/etc/jaeger/ui-config.json
|
|
|
|
|
networks:
|
|
|
|
|
- tyapi-network
|
|
|
|
|
healthcheck:
|
|
|
|
|
test:
|
|
|
|
|
[
|
|
|
|
|
"CMD",
|
|
|
|
|
"wget",
|
|
|
|
|
"--no-verbose",
|
|
|
|
|
"--tries=1",
|
|
|
|
|
"--spider",
|
|
|
|
|
"http://localhost:14269/health",
|
|
|
|
|
]
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 10s
|
|
|
|
|
retries: 3
|
|
|
|
|
start_period: 30s
|
2025-06-30 19:21:56 +08:00
|
|
|
|
2025-07-02 16:17:59 +08:00
|
|
|
# Prometheus 监控
|
|
|
|
|
prometheus:
|
|
|
|
|
image: prom/prometheus:main
|
|
|
|
|
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
|
2025-06-30 19:21:56 +08:00
|
|
|
|
2025-07-02 16:17:59 +08:00
|
|
|
# Grafana 仪表盘
|
|
|
|
|
grafana:
|
|
|
|
|
image: grafana/grafana:12.0.2
|
|
|
|
|
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
|
2025-06-30 19:21:56 +08:00
|
|
|
|
2025-07-02 16:17:59 +08:00
|
|
|
# MinIO 对象存储 (S3兼容)
|
|
|
|
|
minio:
|
|
|
|
|
image: minio/minio:RELEASE.2025-06-13T11-33-47Z-cpuv1
|
|
|
|
|
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
|
2025-06-30 19:21:56 +08:00
|
|
|
|
2025-07-02 16:17:59 +08:00
|
|
|
# Mailhog 邮件测试服务
|
|
|
|
|
mailhog:
|
|
|
|
|
image: mailhog/mailhog:v1.0.1
|
|
|
|
|
container_name: tyapi-mailhog
|
|
|
|
|
ports:
|
|
|
|
|
- "1025:1025" # SMTP
|
|
|
|
|
- "8025:8025" # Web UI
|
|
|
|
|
networks:
|
|
|
|
|
- tyapi-network
|
2025-06-30 19:21:56 +08:00
|
|
|
|
2025-07-02 16:17:59 +08:00
|
|
|
# pgAdmin 数据库管理
|
|
|
|
|
pgadmin:
|
|
|
|
|
image: dpage/pgadmin4:snapshot
|
|
|
|
|
container_name: tyapi-pgadmin
|
|
|
|
|
environment:
|
|
|
|
|
PGADMIN_DEFAULT_EMAIL: admin@tyapi.com
|
|
|
|
|
PGADMIN_DEFAULT_PASSWORD: Pa4dG9wF2sL6tN8u
|
|
|
|
|
PGADMIN_CONFIG_SERVER_MODE: "True"
|
|
|
|
|
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
|
|
|
|
|
PGADMIN_CONFIG_UPGRADE_CHECK_ENABLED: "False"
|
|
|
|
|
ports:
|
|
|
|
|
- "5050:80"
|
|
|
|
|
volumes:
|
|
|
|
|
- pgadmin_data:/var/lib/pgadmin
|
|
|
|
|
- ./deployments/docker/pgadmin-servers.json:/pgadmin4/servers.json
|
|
|
|
|
- ./deployments/docker/pgadmin-passfile:/var/lib/pgadmin/passfile
|
|
|
|
|
networks:
|
|
|
|
|
- tyapi-network
|
|
|
|
|
depends_on:
|
|
|
|
|
- postgres
|
2025-06-30 19:21:56 +08:00
|
|
|
|
|
|
|
|
volumes:
|
2025-07-02 16:17:59 +08:00
|
|
|
postgres_data:
|
|
|
|
|
driver: local
|
|
|
|
|
redis_data:
|
|
|
|
|
driver: local
|
|
|
|
|
prometheus_data:
|
|
|
|
|
driver: local
|
|
|
|
|
grafana_data:
|
|
|
|
|
driver: local
|
|
|
|
|
minio_data:
|
|
|
|
|
driver: local
|
|
|
|
|
pgadmin_data:
|
|
|
|
|
driver: local
|
2025-06-30 19:21:56 +08:00
|
|
|
|
|
|
|
|
networks:
|
2025-07-02 16:17:59 +08:00
|
|
|
tyapi-network:
|
|
|
|
|
driver: bridge
|