Dockerfile 775 B

1234567891011121314151617181920212223242526
  1. FROM registry.cn-hangzhou.aliyuncs.com/stuuudy/python:3.11-slim AS base
  2. WORKDIR /app
  3. ENV PYTHONDONTWRITEBYTECODE=1 \
  4. PYTHONUNBUFFERED=1
  5. # 安装编译工具链(某些依赖如 pyfim 构建 wheel 需要 gcc)
  6. RUN apt-get update && \
  7. apt-get install -y --no-install-recommends gcc g++ libc6-dev && \
  8. rm -rf /var/lib/apt/lists/*
  9. # 1) 安装依赖(利用 Docker layer 缓存)
  10. COPY requirements.txt /app/requirements.txt
  11. RUN pip install --no-cache-dir --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
  12. RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
  13. # 2) 复制源码
  14. COPY . /app
  15. EXPOSE 7000
  16. # demand Web API
  17. CMD ["uvicorn", "examples.demand.web_api:app", "--host", "0.0.0.0", "--port", "7000"]