services: backend: build: target: builder # 使用 builder 阶段,保留完整工具链 volumes: - .:/app # 挂载源码目录,支持热重载 - /app/.venv # 防止宿主机 .venv 覆盖容器内的 .venv command: uvicorn server:app --host 0.0.0.0 --port 3001 --reload env_file: - .env environment: - LOG_LEVEL=debug ports: - "${PORT:-3001}:3001" restart: "no" # 开发时不自动重启,报错立即停止方便排查