video-compliance-ai/docker-compose.yml
Your Name 86a7865808 feat: 添加 Docker 部署配置 + 安全加固 + 数据导出 API
- 新增 backend/Dockerfile + frontend/Dockerfile (多阶段构建)
- 新增 docker-compose.yml (postgres + redis + backend + frontend)
- 新增 .env.example 模板 (前后端)
- 新增 export API: 任务数据导出 + 审计日志导出 (CSV + 流式响应)
- 安全加固: CORS 从环境变量配置, 安全 headers 中间件
- 生产环境自动禁用 API 文档 (Swagger/Redoc)
- 添加 ENVIRONMENT, CORS_ORIGINS 配置项
- 前端启用 Next.js standalone 输出模式

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 17:43:28 +08:00

82 lines
2.0 KiB
YAML

version: "3.8"
services:
# ---- PostgreSQL 数据库 ----
postgres:
image: postgres:16-alpine
container_name: miaosi-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-miaosi}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
# ---- Redis 缓存 / 消息队列 ----
redis:
image: redis:7-alpine
container_name: miaosi-redis
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
# ---- FastAPI 后端 ----
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: miaosi-backend
ports:
- "${BACKEND_PORT:-8000}:8000"
env_file:
- ./backend/.env
environment:
# 覆盖数据库和 Redis 地址,指向 Docker 内部网络
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/${POSTGRES_DB:-miaosi}
REDIS_URL: redis://redis:6379/0
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- video_temp:/tmp/videos
restart: unless-stopped
# ---- Next.js 前端 ----
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL:-http://localhost:8000}
NEXT_PUBLIC_USE_MOCK: "false"
container_name: miaosi-frontend
ports:
- "${FRONTEND_PORT:-3000}:3000"
environment:
NODE_ENV: production
depends_on:
- backend
restart: unless-stopped
volumes:
postgres_data:
redis_data:
video_temp: