Dockerfile 672 B

1234567891011121314151617181920212223242526272829
  1. # 使用官方轻量级 Python 镜像
  2. FROM python:3.9-slim
  3. # 设置工作目录
  4. WORKDIR /app
  5. # 设置环境变量
  6. ENV PYTHONDONTWRITEBYTECODE 1
  7. ENV PYTHONUNBUFFERED 1
  8. # 安装 curl 用于健康检查
  9. #RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
  10. # 复制依赖文件
  11. COPY requirements.txt .
  12. # 安装 Python 依赖(使用国内镜像源)
  13. RUN pip install --no-cache-dir -r requirements.txt \
  14. -i https://pypi.tuna.tsinghua.edu.cn/simple/ \
  15. --trusted-host pypi.tuna.tsinghua.edu.cn
  16. # 复制项目代码
  17. COPY . .
  18. # 暴露端口
  19. EXPOSE 9002
  20. # 启动命令
  21. CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "9002"]