FROM python:3.11-slim WORKDIR /app # 安装必要的系统构建工具和 git RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git \ && rm -rf /var/lib/apt/lists/* # 先精准安装 CPU 版 PyTorch,防止镜像体积过大 RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu # 安装基础运行库 RUN pip install --no-cache-dir fastapi uvicorn pydantic numpy # 【核心修复】绕过 PyPI,直接从 GitHub 源码安装最新 TimesFM 及其 torch 依赖 RUN pip install --no-cache-dir "timesfm[torch] @ git+https://github.com/google-research/timesfm.git" COPY app.py . EXPOSE 7860 CMD ["python", "app.py"]