2025-10-30 11:14:43 +08:00
|
|
|
|
services:
|
2025-11-10 21:16:55 +08:00
|
|
|
|
postgres:
|
|
|
|
|
|
image: postgres:18-alpine
|
|
|
|
|
|
container_name: mumuainovel-postgres
|
|
|
|
|
|
environment:
|
|
|
|
|
|
POSTGRES_DB: mumuai_novel
|
|
|
|
|
|
POSTGRES_USER: mumuai
|
|
|
|
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-mumuai_password_2024}
|
|
|
|
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
|
|
|
|
|
|
TZ: Asia/Shanghai
|
|
|
|
|
|
volumes:
|
|
|
|
|
|
- postgres_data:/var/lib/postgresql/data
|
|
|
|
|
|
- ./backend/scripts/init_postgres.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
|
|
|
|
|
ports:
|
|
|
|
|
|
- "5432:5432"
|
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
healthcheck:
|
|
|
|
|
|
test: ["CMD-SHELL", "pg_isready -U mumuai -d mumuai_novel"]
|
|
|
|
|
|
interval: 10s
|
|
|
|
|
|
timeout: 5s
|
|
|
|
|
|
retries: 5
|
|
|
|
|
|
start_period: 10s
|
|
|
|
|
|
networks:
|
|
|
|
|
|
- ai-story-network
|
|
|
|
|
|
command:
|
|
|
|
|
|
- postgres
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- max_connections=200
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- shared_buffers=256MB
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- effective_cache_size=1GB
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- maintenance_work_mem=64MB
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- checkpoint_completion_target=0.9
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- wal_buffers=16MB
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- default_statistics_target=100
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- random_page_cost=1.1
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- effective_io_concurrency=200
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- work_mem=4MB
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- min_wal_size=1GB
|
|
|
|
|
|
- -c
|
|
|
|
|
|
- max_wal_size=4GB
|
|
|
|
|
|
|
2025-11-06 16:15:08 +08:00
|
|
|
|
mumuainovel:
|
2025-10-30 11:14:43 +08:00
|
|
|
|
build:
|
|
|
|
|
|
context: .
|
|
|
|
|
|
dockerfile: Dockerfile
|
2025-11-06 16:15:08 +08:00
|
|
|
|
image: mumujie/mumuainovel:latest
|
|
|
|
|
|
container_name: mumuainovel
|
2025-11-10 21:16:55 +08:00
|
|
|
|
depends_on:
|
|
|
|
|
|
postgres:
|
|
|
|
|
|
condition: service_healthy
|
2025-10-30 11:14:43 +08:00
|
|
|
|
ports:
|
|
|
|
|
|
- "8000:8000"
|
|
|
|
|
|
volumes:
|
2025-11-10 21:16:55 +08:00
|
|
|
|
# 持久化日志
|
2025-10-30 11:14:43 +08:00
|
|
|
|
- ./logs:/app/logs
|
|
|
|
|
|
# 挂载环境变量文件(可选)
|
|
|
|
|
|
- ./.env:/app/.env:ro
|
|
|
|
|
|
environment:
|
|
|
|
|
|
# 应用配置
|
|
|
|
|
|
- APP_NAME=AI Story Creator
|
|
|
|
|
|
- APP_VERSION=1.0.0
|
|
|
|
|
|
- APP_HOST=0.0.0.0
|
|
|
|
|
|
- APP_PORT=8000
|
|
|
|
|
|
- DEBUG=false
|
|
|
|
|
|
|
2025-11-10 21:16:55 +08:00
|
|
|
|
# 数据库配置(使用PostgreSQL)
|
|
|
|
|
|
- DATABASE_URL=postgresql+asyncpg://mumuai:${POSTGRES_PASSWORD:-mumuai_password_2024}@postgres:5432/mumuai_novel
|
|
|
|
|
|
|
|
|
|
|
|
# PostgreSQL连接池配置
|
|
|
|
|
|
- DATABASE_POOL_SIZE=30
|
|
|
|
|
|
- DATABASE_MAX_OVERFLOW=20
|
|
|
|
|
|
- DATABASE_POOL_TIMEOUT=60
|
|
|
|
|
|
- DATABASE_POOL_RECYCLE=1800
|
|
|
|
|
|
- DATABASE_POOL_PRE_PING=True
|
|
|
|
|
|
- DATABASE_POOL_USE_LIFO=True
|
|
|
|
|
|
|
|
|
|
|
|
- HTTP_PROXY=http://172.16.66.175:7890
|
|
|
|
|
|
- HTTPS_PROXY=http://172.16.66.175:7890
|
|
|
|
|
|
- NO_PROXY=localhost,127.0.0.1
|
2025-10-30 11:14:43 +08:00
|
|
|
|
|
|
|
|
|
|
# AI服务配置(建议在 .env 文件中设置)
|
|
|
|
|
|
# - OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
|
|
|
|
# - GEMINI_API_KEY=${GEMINI_API_KEY}
|
|
|
|
|
|
# - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
|
|
|
|
|
# - DEFAULT_AI_PROVIDER=${DEFAULT_AI_PROVIDER:-gemini}
|
|
|
|
|
|
# - DEFAULT_MODEL=${DEFAULT_MODEL:-gemini-2.5-flash}
|
|
|
|
|
|
|
|
|
|
|
|
# LinuxDO OAuth配置(⚠️ 必须设置正确的回调地址)
|
|
|
|
|
|
# - LINUXDO_CLIENT_ID=${LINUXDO_CLIENT_ID}
|
|
|
|
|
|
# - LINUXDO_CLIENT_SECRET=${LINUXDO_CLIENT_SECRET}
|
|
|
|
|
|
# - LINUXDO_REDIRECT_URI=${LINUXDO_REDIRECT_URI}
|
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
healthcheck:
|
|
|
|
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
|
|
|
|
|
|
interval: 30s
|
|
|
|
|
|
timeout: 10s
|
|
|
|
|
|
retries: 3
|
2025-11-10 21:16:55 +08:00
|
|
|
|
start_period: 30s
|
2025-10-30 11:14:43 +08:00
|
|
|
|
networks:
|
|
|
|
|
|
- ai-story-network
|
|
|
|
|
|
|
2025-11-10 21:16:55 +08:00
|
|
|
|
volumes:
|
|
|
|
|
|
postgres_data:
|
|
|
|
|
|
driver: local
|
|
|
|
|
|
|
2025-10-30 11:14:43 +08:00
|
|
|
|
networks:
|
|
|
|
|
|
ai-story-network:
|
|
|
|
|
|
driver: bridge
|
2025-11-10 21:16:55 +08:00
|
|
|
|
|