Dockerfile 871 B

1234567891011121314151617181920212223242526272829303132333435
  1. # 使用轻量级 Python 基础镜像
  2. FROM python:3.11-slim
  3. # 设置工作目录
  4. WORKDIR /app
  5. # 环境变量优化
  6. ENV PYTHONDONTWRITEBYTECODE=1 \
  7. PYTHONUNBUFFERED=1 \
  8. PIP_DISABLE_PIP_VERSION_CHECK=on \
  9. TZ=Asia/Shanghai \
  10. PATH="/root/.local/bin:$PATH"
  11. # 安装系统依赖(构建 wheel、时区等)
  12. RUN apt-get update && apt-get install -y --no-install-recommends \
  13. build-essential \
  14. curl \
  15. tzdata \
  16. && rm -rf /var/lib/apt/lists/*
  17. # 设置时区
  18. RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
  19. # 复制 requirements 并安装依赖
  20. COPY requirements.txt .
  21. RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
  22. # 复制项目文件
  23. COPY . .
  24. # 暴露端口
  25. EXPOSE 8001
  26. # 启动命令
  27. CMD ["hypercorn", "vector_app:app", "--config", "config.toml"]