- env.py: 自动创建 alembic_version 表时使用 VARCHAR(255) 避免截断 - docker-compose: 添加 frontend nginx 服务 + alembic 挂载 - nginx.conf: SPA 路由 + API 代理
44 lines
1.1 KiB
YAML
44 lines
1.1 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:?POSTGRES_USER 未设置}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD 未设置}
|
|
POSTGRES_DB: ${POSTGRES_DB:-football}
|
|
ports:
|
|
- "${POSTGRES_PORT:-5433}:5432"
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:?POSTGRES_USER 未设置}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
api:
|
|
build: .
|
|
command: uvicorn src.api.app:app --host 0.0.0.0 --port 8000 --reload
|
|
ports:
|
|
- "${API_PORT:-8000}:8000"
|
|
env_file: .env
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./src:/app/src
|
|
- ./alembic:/app/alembic
|
|
- ./alembic.ini:/app/alembic.ini
|
|
|
|
frontend:
|
|
image: nginx:alpine
|
|
ports:
|
|
- "${FRONTEND_PORT:-3000}:80"
|
|
volumes:
|
|
- ./frontend/dist:/usr/share/nginx/html
|
|
- ./frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
depends_on:
|
|
- api
|
|
|
|
volumes:
|
|
pgdata:
|