29 lines
920 B
YAML
29 lines
920 B
YAML
version: '3.8'
|
|
|
|
services:
|
|
db:
|
|
image: postgres:15
|
|
environment:
|
|
POSTGRES_USER: user
|
|
POSTGRES_PASSWORD: password
|
|
POSTGRES_DB: fastapi_db
|
|
ports:
|
|
- "5432:5432"
|
|
|
|
web:
|
|
image: python:3.11-slim
|
|
command: >
|
|
sh -c "pip install -r requirements.txt && python -Xfrozen_modules=off -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
|
|
# 需要debug时使用
|
|
# sh -c "pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
|
|
volumes:
|
|
- .:/code
|
|
working_dir: /code
|
|
ports:
|
|
- "8000:8000"
|
|
- "5678:5678" # 暴露调试端口
|
|
environment:
|
|
- DATABASE_URL=postgresql+asyncpg://user:password@db:5432/fastapi_db
|
|
- GEMINI_API_KEY=key_here
|
|
depends_on:
|
|
- db |