feat(feishu): 添加飞书入站事件inbox和混合数据库协调功能 - 实现飞书入站事件持久化inbox机制,支持状态管理、租约锁定和重试退避 - 添加混合数据库基线协调工具,确保平台PostgreSQL结构安全对齐 - 增加运行组件心跳检测和readiness就绪检查机制 - 实现app_ticket事件的安全轮换和验证处理 - 添加生产环境运行编排和fail-closed安全机制 - 支持webhook快速确认和长连接独立进程处理 - 完善个人数据擦除时的待处理事件清理功能 ```
139 lines
3.9 KiB
YAML
139 lines
3.9 KiB
YAML
x-app-env-files: &app-env-files
|
|
- path: .env
|
|
required: true
|
|
|
|
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-company_ai}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-}
|
|
POSTGRES_DB: ${POSTGRES_DB:-company_ai}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
migrate:
|
|
build: .
|
|
env_file: *app-env-files
|
|
environment:
|
|
APP_ENV: production
|
|
DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}"
|
|
REDIS_URL: redis://redis:6379/0
|
|
command: ["alembic", "upgrade", "head"]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: "no"
|
|
|
|
api:
|
|
build: .
|
|
env_file: *app-env-files
|
|
environment:
|
|
APP_ENV: production
|
|
DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}"
|
|
REDIS_URL: redis://redis:6379/0
|
|
SCHEDULER_ENABLED: "false"
|
|
TASK_QUEUE_ENABLED: "true"
|
|
ports:
|
|
- "8010:8010"
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
healthcheck:
|
|
test:
|
|
[
|
|
"CMD",
|
|
"python",
|
|
"-c",
|
|
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8010/api/v1/health/ready', timeout=3).read()",
|
|
]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
restart: unless-stopped
|
|
|
|
worker:
|
|
build: .
|
|
env_file: *app-env-files
|
|
environment:
|
|
APP_ENV: production
|
|
DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}"
|
|
REDIS_URL: redis://redis:6379/0
|
|
TASK_QUEUE_ENABLED: "true"
|
|
SCHEDULER_ENABLED: "false"
|
|
command: ["celery", "-A", "app.tasks:celery_app", "worker", "--loglevel=info"]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
restart: unless-stopped
|
|
|
|
scheduler:
|
|
build: .
|
|
env_file: *app-env-files
|
|
environment:
|
|
APP_ENV: production
|
|
DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}"
|
|
REDIS_URL: redis://redis:6379/0
|
|
SCHEDULER_ENABLED: "true"
|
|
TASK_QUEUE_ENABLED: "true"
|
|
command: ["python", "-m", "app.tools.run_scheduler"]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
restart: unless-stopped
|
|
|
|
feishu-events:
|
|
build: .
|
|
profiles: ["long-connection"]
|
|
env_file: *app-env-files
|
|
environment:
|
|
APP_ENV: production
|
|
DATABASE_URL: "${COMPOSE_DATABASE_URL:-postgresql+psycopg://${POSTGRES_USER:-company_ai}:${POSTGRES_PASSWORD:-}@db:5432/${POSTGRES_DB:-company_ai}}"
|
|
REDIS_URL: redis://redis:6379/0
|
|
FEISHU_EVENT_TRANSPORT: long_connection
|
|
SCHEDULER_ENABLED: "false"
|
|
TASK_QUEUE_ENABLED: "true"
|
|
command: ["python", "-m", "app.modules.feishu.long_connection"]
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|