2026-01-18 15:58:05 +08:00
|
|
|
|
services:
|
2026-01-21 23:21:36 +01:00
|
|
|
|
# PostgreSQL 数据库(使用最新版 17)
|
|
|
|
|
|
postgres:
|
2026-03-23 09:20:38 +08:00
|
|
|
|
image: m.daocloud.io/docker.io/pgvector/pgvector:pg17
|
2026-01-21 23:21:36 +01:00
|
|
|
|
container_name: life-echo-postgres
|
2026-02-14 13:36:17 +01:00
|
|
|
|
ports:
|
2026-05-08 17:28:31 +08:00
|
|
|
|
# 宿主机端口随机,避免与本机其它 PostgreSQL 冲突;查询: docker compose port postgres 5432
|
|
|
|
|
|
- "127.0.0.1::5432"
|
2026-01-21 23:21:36 +01:00
|
|
|
|
environment:
|
|
|
|
|
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
|
|
|
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
|
|
|
|
|
POSTGRES_DB: ${POSTGRES_DB:-life_echo}
|
|
|
|
|
|
volumes:
|
|
|
|
|
|
- postgres_data:/var/lib/postgresql/data
|
|
|
|
|
|
restart: always
|
|
|
|
|
|
healthcheck:
|
|
|
|
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
|
|
|
|
interval: 10s
|
|
|
|
|
|
timeout: 5s
|
|
|
|
|
|
retries: 5
|
|
|
|
|
|
networks:
|
|
|
|
|
|
- life-echo-network
|
|
|
|
|
|
logging:
|
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
|
options:
|
|
|
|
|
|
max-size: "10m"
|
|
|
|
|
|
max-file: "3"
|
|
|
|
|
|
|
2026-01-21 23:06:47 +01:00
|
|
|
|
# Redis 服务(用于会话存储和 Celery 消息队列)
|
|
|
|
|
|
redis:
|
2026-03-22 20:27:16 +08:00
|
|
|
|
image: m.daocloud.io/docker.io/library/redis:7-alpine
|
2026-01-21 23:06:47 +01:00
|
|
|
|
container_name: life-echo-redis
|
2026-01-27 23:18:53 +01:00
|
|
|
|
# ports:
|
|
|
|
|
|
# - "6379:6379" # 不暴露到宿主机,仅在 Docker 网络内部访问
|
2026-01-21 23:06:47 +01:00
|
|
|
|
volumes:
|
|
|
|
|
|
- redis_data:/data
|
|
|
|
|
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
|
|
|
|
|
restart: always
|
|
|
|
|
|
healthcheck:
|
|
|
|
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
|
|
|
|
interval: 10s
|
|
|
|
|
|
timeout: 5s
|
|
|
|
|
|
retries: 5
|
|
|
|
|
|
networks:
|
|
|
|
|
|
- life-echo-network
|
|
|
|
|
|
logging:
|
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
|
options:
|
|
|
|
|
|
max-size: "10m"
|
|
|
|
|
|
max-file: "3"
|
|
|
|
|
|
|
|
|
|
|
|
# FastAPI 应用
|
2026-03-23 13:21:07 +08:00
|
|
|
|
# 运行时统一读取 .env;部署时在远端将 .env.staging 或 .env.production 复制为 .env。
|
2026-01-18 15:58:05 +08:00
|
|
|
|
api:
|
|
|
|
|
|
build:
|
|
|
|
|
|
context: .
|
|
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
|
image: life-echo-api:latest
|
|
|
|
|
|
container_name: life-echo-api-prod
|
2026-05-08 17:28:31 +08:00
|
|
|
|
# 独立 Caddy 反代;绑定本机回环。未设置 LIFE_ECHO_API_HOST_PORT 时宿主机端口随机,避免与机上其它服务冲突。
|
|
|
|
|
|
# 需固定端口时(例如 Caddyfile):在 .env 设置 LIFE_ECHO_API_HOST_PORT=8000;随机时查询: docker compose port api 8000
|
2026-03-25 10:26:21 +08:00
|
|
|
|
ports:
|
2026-05-08 17:28:31 +08:00
|
|
|
|
- "127.0.0.1:${LIFE_ECHO_API_HOST_PORT:-}:8000"
|
2026-01-18 15:58:05 +08:00
|
|
|
|
env_file:
|
2026-03-23 13:21:07 +08:00
|
|
|
|
- .env
|
2026-01-21 23:06:47 +01:00
|
|
|
|
environment:
|
2026-02-10 15:08:00 +08:00
|
|
|
|
- ASR_MODEL_CACHE_DIR=/app/models/whisper
|
2026-04-01 16:14:38 +08:00
|
|
|
|
- ALEMBIC_STARTUP_FAIL_FAST=true
|
2026-04-08 21:36:12 +08:00
|
|
|
|
- APP_ENV=production
|
2026-02-13 21:30:18 +01:00
|
|
|
|
volumes:
|
|
|
|
|
|
- /root/apiclient_key.pem:/app/certs/apiclient_key.pem:ro
|
2026-01-18 15:58:05 +08:00
|
|
|
|
restart: always
|
2026-01-21 23:06:47 +01:00
|
|
|
|
depends_on:
|
2026-01-21 23:21:36 +01:00
|
|
|
|
postgres:
|
|
|
|
|
|
condition: service_healthy
|
2026-01-21 23:06:47 +01:00
|
|
|
|
redis:
|
|
|
|
|
|
condition: service_healthy
|
2026-01-18 15:58:05 +08:00
|
|
|
|
healthcheck:
|
2026-01-18 17:09:10 +08:00
|
|
|
|
test: ["CMD", "python", "-c", "import http.client; conn = http.client.HTTPConnection('localhost', 8000); conn.request('GET', '/health'); r = conn.getresponse(); exit(0 if r.status == 200 else 1)"]
|
2026-04-01 16:14:38 +08:00
|
|
|
|
interval: 15s
|
|
|
|
|
|
timeout: 5s
|
|
|
|
|
|
retries: 6
|
|
|
|
|
|
start_period: 120s
|
2026-01-18 15:58:05 +08:00
|
|
|
|
networks:
|
|
|
|
|
|
- life-echo-network
|
2026-01-18 17:09:10 +08:00
|
|
|
|
logging:
|
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
|
options:
|
|
|
|
|
|
max-size: "10m"
|
|
|
|
|
|
max-file: "3"
|
2026-01-21 23:06:47 +01:00
|
|
|
|
|
2026-02-11 18:34:22 +01:00
|
|
|
|
# Celery Worker(后台任务处理,禁用镜像内置的 8000 端口健康检查,改用 celery inspect ping)
|
2026-01-21 23:06:47 +01:00
|
|
|
|
celery-worker:
|
|
|
|
|
|
build:
|
|
|
|
|
|
context: .
|
|
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
|
image: life-echo-api:latest
|
|
|
|
|
|
container_name: life-echo-celery-worker
|
feat(eval): memoir A/B chapter judging and eval-web parity with dialogue
- Judge baseline excerpt and library chapter separately; build_memoir_compare_summary for gate, nine-dim and leaf deltas.
- Memoir SSE chapter payload: baseline_judge, compare_summary, baseline_judge_error.
- MemoirJudgeOutput: loose score coercion and post-validate clamp; memoir judge prompt caps from settings.
- app-eval-web: two-column MemoirScoreCard layout, MemoirCompareSummary, chapter blocks and CSS.
- Add memoir_compare_summary, log_events, celery_log_context, memoir_pipeline_progress; tests and migration 0014.
- Misc: memory/evidence and enrichment paths, task/orchestrator updates, internal-eval docs, env examples.
2026-04-10 10:23:43 +08:00
|
|
|
|
command: uv run celery -A app.tasks.celery_app worker --loglevel=info --concurrency=4 -Q celery,memory_idle
|
2026-01-21 23:06:47 +01:00
|
|
|
|
env_file:
|
2026-03-23 13:21:07 +08:00
|
|
|
|
- .env
|
2026-04-08 21:36:12 +08:00
|
|
|
|
environment:
|
|
|
|
|
|
- APP_ENV=production
|
2026-01-21 23:06:47 +01:00
|
|
|
|
restart: always
|
|
|
|
|
|
depends_on:
|
2026-01-21 23:21:36 +01:00
|
|
|
|
postgres:
|
|
|
|
|
|
condition: service_healthy
|
2026-01-21 23:06:47 +01:00
|
|
|
|
redis:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
api:
|
|
|
|
|
|
condition: service_healthy
|
2026-02-11 18:34:22 +01:00
|
|
|
|
healthcheck:
|
2026-03-23 10:25:51 +08:00
|
|
|
|
test: ["CMD-SHELL", "uv run celery -A app.tasks.celery_app inspect ping --timeout 10 2>/dev/null | grep -q pong || exit 1"]
|
2026-02-11 18:34:22 +01:00
|
|
|
|
interval: 30s
|
|
|
|
|
|
timeout: 15s
|
|
|
|
|
|
retries: 3
|
|
|
|
|
|
start_period: 30s
|
2026-01-21 23:06:47 +01:00
|
|
|
|
networks:
|
|
|
|
|
|
- life-echo-network
|
|
|
|
|
|
logging:
|
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
|
options:
|
|
|
|
|
|
max-size: "10m"
|
|
|
|
|
|
max-file: "3"
|
|
|
|
|
|
|
2026-04-03 11:43:16 +08:00
|
|
|
|
celery-beat:
|
|
|
|
|
|
build:
|
|
|
|
|
|
context: .
|
|
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
|
image: life-echo-api:latest
|
|
|
|
|
|
container_name: life-echo-celery-beat
|
|
|
|
|
|
command: uv run celery -A app.tasks.celery_app beat --loglevel=info
|
|
|
|
|
|
env_file:
|
|
|
|
|
|
- .env
|
2026-04-08 21:36:12 +08:00
|
|
|
|
environment:
|
|
|
|
|
|
- APP_ENV=production
|
2026-04-03 11:43:16 +08:00
|
|
|
|
restart: always
|
|
|
|
|
|
depends_on:
|
|
|
|
|
|
postgres:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
redis:
|
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
|
celery-worker:
|
|
|
|
|
|
condition: service_started
|
|
|
|
|
|
networks:
|
|
|
|
|
|
- life-echo-network
|
|
|
|
|
|
logging:
|
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
|
options:
|
|
|
|
|
|
max-size: "10m"
|
|
|
|
|
|
max-file: "3"
|
2026-01-21 23:06:47 +01:00
|
|
|
|
|
|
|
|
|
|
# Flower(Celery 监控面板,可选)
|
|
|
|
|
|
# flower:
|
|
|
|
|
|
# build:
|
|
|
|
|
|
# context: .
|
|
|
|
|
|
# dockerfile: Dockerfile
|
|
|
|
|
|
# image: life-echo-api:latest
|
|
|
|
|
|
# container_name: life-echo-flower
|
2026-03-18 17:18:23 +08:00
|
|
|
|
# command: celery -A app.tasks.celery_app flower --port=5555
|
2026-01-21 23:06:47 +01:00
|
|
|
|
# ports:
|
|
|
|
|
|
# - "5555:5555"
|
|
|
|
|
|
# env_file:
|
2026-03-23 13:21:07 +08:00
|
|
|
|
# - .env
|
2026-01-21 23:06:47 +01:00
|
|
|
|
# environment:
|
|
|
|
|
|
# - REDIS_URL=redis://redis:6379/0
|
|
|
|
|
|
# restart: always
|
|
|
|
|
|
# depends_on:
|
|
|
|
|
|
# redis:
|
|
|
|
|
|
# condition: service_healthy
|
|
|
|
|
|
# networks:
|
|
|
|
|
|
# - life-echo-network
|
2026-01-18 15:58:05 +08:00
|
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
|
life-echo-network:
|
2026-01-28 12:59:03 +08:00
|
|
|
|
external: true
|
2026-01-28 16:05:05 +08:00
|
|
|
|
name: api_life-echo-network
|
2026-01-21 23:06:47 +01:00
|
|
|
|
|
|
|
|
|
|
volumes:
|
2026-01-21 23:21:36 +01:00
|
|
|
|
postgres_data:
|
|
|
|
|
|
driver: local
|
2026-01-21 23:06:47 +01:00
|
|
|
|
redis_data:
|
|
|
|
|
|
driver: local
|