2025-12-12 18:04:57 +08:00
|
|
|
|
# ============================================
|
|
|
|
|
|
# 生产环境配置 - 使用 Docker Hub 预构建镜像
|
|
|
|
|
|
# ============================================
|
|
|
|
|
|
# 用法: docker compose up -d
|
|
|
|
|
|
#
|
|
|
|
|
|
# 开发环境请使用: docker compose -f docker-compose.dev.yml up -d
|
|
|
|
|
|
# ============================================
|
|
|
|
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
# PostgreSQL(可选,使用远程数据库时不启动)
|
2026-01-02 22:46:40 +08:00
|
|
|
|
# 使用自定义镜像,预装 pg_ivm 扩展
|
2025-12-12 18:04:57 +08:00
|
|
|
|
postgres:
|
|
|
|
|
|
profiles: ["local-db"]
|
2026-01-02 22:46:40 +08:00
|
|
|
|
build:
|
|
|
|
|
|
context: ./postgres
|
|
|
|
|
|
dockerfile: Dockerfile
|
2026-01-03 17:26:34 +08:00
|
|
|
|
image: ${DOCKER_USER:-yyhuni}/xingrin-postgres:${IMAGE_TAG:?IMAGE_TAG is required}
|
2025-12-12 18:04:57 +08:00
|
|
|
|
restart: always
|
|
|
|
|
|
environment:
|
|
|
|
|
|
POSTGRES_DB: ${DB_NAME}
|
|
|
|
|
|
POSTGRES_USER: ${DB_USER}
|
|
|
|
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
|
|
|
|
volumes:
|
|
|
|
|
|
- postgres_data:/var/lib/postgresql/data
|
|
|
|
|
|
- ./postgres/init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh
|
|
|
|
|
|
ports:
|
|
|
|
|
|
- "${DB_PORT}:5432"
|
2026-01-02 22:46:40 +08:00
|
|
|
|
command: >
|
|
|
|
|
|
postgres
|
|
|
|
|
|
-c shared_preload_libraries=pg_ivm
|
2025-12-12 18:04:57 +08:00
|
|
|
|
healthcheck:
|
|
|
|
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
|
|
|
|
|
|
interval: 5s
|
|
|
|
|
|
timeout: 5s
|
|
|
|
|
|
retries: 5
|
|
|
|
|
|
|
|
|
|
|
|
redis:
|
|
|
|
|
|
image: redis:7-alpine
|
|
|
|
|
|
restart: always
|
|
|
|
|
|
healthcheck:
|
|
|
|
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
|
|
|
|
interval: 5s
|
|
|
|
|
|
timeout: 5s
|
|
|
|
|
|
retries: 5
|
|
|
|
|
|
|
|
|
|
|
|
server:
|
2025-12-15 11:47:06 +08:00
|
|
|
|
image: ${DOCKER_USER:-yyhuni}/xingrin-server:${IMAGE_TAG:?IMAGE_TAG is required}
|
2025-12-12 18:04:57 +08:00
|
|
|
|
restart: always
|
|
|
|
|
|
env_file:
|
|
|
|
|
|
- .env
|
|
|
|
|
|
depends_on:
|
|
|
|
|
|
redis:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
volumes:
|
2025-12-29 20:43:49 +08:00
|
|
|
|
# 统一挂载数据目录
|
|
|
|
|
|
- /opt/xingrin:/opt/xingrin
|
2025-12-12 18:04:57 +08:00
|
|
|
|
# Docker Socket 挂载:允许 Django 服务器执行本地 docker 命令(用于本地 Worker 任务分发)
|
|
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
|
|
|
|
healthcheck:
|
2025-12-31 22:21:40 +08:00
|
|
|
|
# 使用专门的健康检查端点(无需认证)
|
|
|
|
|
|
test: ["CMD", "curl", "-f", "http://localhost:8888/api/health/"]
|
2025-12-12 18:04:57 +08:00
|
|
|
|
interval: 30s
|
|
|
|
|
|
timeout: 10s
|
|
|
|
|
|
retries: 3
|
|
|
|
|
|
start_period: 60s
|
|
|
|
|
|
|
|
|
|
|
|
# ============================================
|
|
|
|
|
|
# Agent:轻量心跳上报 + 负载监控(~10MB)
|
|
|
|
|
|
# 扫描任务通过 task_distributor 分发到动态容器
|
|
|
|
|
|
# ============================================
|
|
|
|
|
|
|
|
|
|
|
|
agent:
|
2025-12-15 11:47:06 +08:00
|
|
|
|
image: ${DOCKER_USER:-yyhuni}/xingrin-agent:${IMAGE_TAG:?IMAGE_TAG is required}
|
2025-12-12 18:04:57 +08:00
|
|
|
|
container_name: xingrin-agent
|
|
|
|
|
|
restart: always
|
|
|
|
|
|
environment:
|
|
|
|
|
|
- SERVER_URL=http://server:8888
|
2026-01-01 22:35:05 +08:00
|
|
|
|
- WORKER_NAME=Local-Worker
|
2025-12-12 18:04:57 +08:00
|
|
|
|
- IS_LOCAL=true
|
2025-12-19 19:20:15 +08:00
|
|
|
|
- IMAGE_TAG=${IMAGE_TAG}
|
2025-12-31 20:18:14 +08:00
|
|
|
|
- WORKER_API_KEY=${WORKER_API_KEY}
|
2025-12-12 18:04:57 +08:00
|
|
|
|
depends_on:
|
|
|
|
|
|
server:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
volumes:
|
|
|
|
|
|
- /proc:/host/proc:ro
|
|
|
|
|
|
|
|
|
|
|
|
frontend:
|
2025-12-15 11:47:06 +08:00
|
|
|
|
image: ${DOCKER_USER:-yyhuni}/xingrin-frontend:${IMAGE_TAG:?IMAGE_TAG is required}
|
2025-12-12 18:04:57 +08:00
|
|
|
|
restart: always
|
|
|
|
|
|
depends_on:
|
|
|
|
|
|
server:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
|
|
|
|
|
|
nginx:
|
2025-12-15 11:47:06 +08:00
|
|
|
|
image: ${DOCKER_USER:-yyhuni}/xingrin-nginx:${IMAGE_TAG:?IMAGE_TAG is required}
|
2025-12-12 18:04:57 +08:00
|
|
|
|
restart: always
|
|
|
|
|
|
depends_on:
|
|
|
|
|
|
server:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
frontend:
|
|
|
|
|
|
condition: service_started
|
|
|
|
|
|
ports:
|
2025-12-25 16:02:55 +08:00
|
|
|
|
- "8083:8083"
|
2025-12-12 18:04:57 +08:00
|
|
|
|
volumes:
|
|
|
|
|
|
- ./nginx/ssl:/etc/nginx/ssl:ro
|
|
|
|
|
|
|
|
|
|
|
|
volumes:
|
|
|
|
|
|
postgres_data:
|
|
|
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
|
default:
|
|
|
|
|
|
name: xingrin_network # 固定网络名,不随目录名变化
|