# 使用官方的 Python 3.11 镜像 FROM python:3.11-slim # 设置工作目录 WORKDIR /app # 赋予工作目录合适的权限 (Hugging Face 的安全要求) RUN chmod 777 /app # 将当前目录下的所有文件复制到容器的 /app 目录 COPY . /app/ # 安装依赖 RUN pip install --no-cache-dir -r requirements.txt # 暴露 7860 端口 EXPOSE 7860 # 启动 FastAPI 服务 CMD ["python", "main.py"]