# 使用官方Python镜像 FROM python:3.9-slim # 设置工作目录 WORKDIR /app # 复制依赖文件 COPY requirements.txt . # 安装依赖 RUN pip install --no-cache-dir -r requirements.txt # 复制所有代码 COPY . . # 暴露端口(Hugging Face强制要求7860) EXPOSE 7860 # 启动命令(必须用0.0.0.0监听) CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]