Dockerfile 499 B

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