Dockerfile 1004 B

1234567891011121314151617181920212223242526272829
  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 sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \
  7. apt-get update && \
  8. apt-get install -y --no-install-recommends gcc g++ libc6-dev && \
  9. rm -rf /var/lib/apt/lists/*
  10. # 1) 安装依赖(利用 Docker layer 缓存)
  11. COPY requirements.txt /app/requirements.txt
  12. RUN pip install --no-cache-dir --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
  13. #RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
  14. # 将原来的清华源改为阿里源
  15. RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
  16. # 2) 复制源码
  17. COPY . /app
  18. EXPOSE 7000
  19. # demand Web API
  20. CMD ["uvicorn", "examples.demand.web_api:app", "--host", "0.0.0.0", "--port", "7000"]