FROM python:3.11-slim WORKDIR /app # 安装系统依赖 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libffi-dev \ curl \ && rm -rf /var/lib/apt/lists/* # 安装 Python 依赖 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt \ && pip install --no-cache-dir uvicorn[standard] # 复制应用代码 COPY . . # 暴露端口 EXPOSE 8037 # 启动命令(数据库迁移 + 服务启动) CMD ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8037"]