FROM python:3.10-slim WORKDIR /app # 安装系统依赖 RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # 安装 Python 依赖 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 复制应用代码 COPY . . # 确保目录存在(/data 为 HF Spaces 持久存储) RUN mkdir -p static /data/agents /data/uploads ENV DATA_DIR=/data EXPOSE 7860 # 使用 gunicorn 运行,支持 SSE 流式输出 CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--timeout", "120", "app:app"]