FROM python:3.11-slim # 设置工作目录 WORKDIR /app # 复制依赖文件 COPY requirements.txt . # 安装依赖 RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn --no-cache-dir -r requirements.txt # 复制应用代码和环境变量文件 COPY theme5_ex4_fastapi.py . COPY .env . # 创建数据目录 RUN mkdir tmp # 暴露端口 EXPOSE 8000 # 启动命令 CMD ["uvicorn", "theme5_ex4_fastapi:app", "--host", "0.0.0.0", "--port", "8000"]