Dockerfile 794 B

12345678910111213141516171819202122232425262728
  1. FROM python:3.13-slim
  2. ENV DEBIAN_FRONTEND=noninteractive \
  3. TZ=Asia/Shanghai
  4. # 安装系统依赖包并创建虚拟环境
  5. RUN chmod 777 /tmp \
  6. && python -m venv /venv
  7. ENV PATH="/venv/bin:$PATH"
  8. # 先复制 requirements 文件安装依赖(利用缓存)
  9. COPY requirements.txt /tmp/
  10. RUN /venv/bin/pip config set global.index-url https://mirrors.aliyun.com/pypi/simple \
  11. && /venv/bin/pip config set install.trusted-host mirrors.aliyun.com \
  12. && /venv/bin/pip --default-timeout=1800 install -r /tmp/requirements.txt \
  13. && rm -rf /root/.cache
  14. # 设置工作目录并复制项目文件
  15. WORKDIR /app
  16. COPY . /app
  17. EXPOSE 8001
  18. # 确保脚本可执行
  19. RUN chmod 777 run.sh
  20. # 使用虚拟环境运行脚本
  21. CMD ["/venv/bin/gunicorn", "-c", "gunicorn_config.py", "server.app:app"]