Spaces:
Sleeping
Sleeping
| # 使用官方Python 3.9 slim镜像 | |
| FROM python:3.9-slim | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # --- 1. 准备工作:安装git --- | |
| # 更新包列表并安装git,--no-install-recommends 避免安装不必要的包 | |
| RUN apt-get update && apt-get install -y --no-install-recommends git | |
| # --- 2. 关键步骤:使用现代的、安全的 secrets 挂载方式克隆私有仓库 --- | |
| # 请确保您的 Hugging Face Space Secrets 的名字与这里的 id 完全匹配。 | |
| # id=GH_USER 对应名为 GH_USER 的 secret。 | |
| # id=GH_TOKEN 对应名为 GH_TOKEN 的 secret。 | |
| # | |
| # !! 重要 !! | |
| # 请将下面的 'leoncool23/ducg-modeler-app.git' 替换为您自己的 GitHub 用户名和仓库名。 | |
| RUN --mount=type=secret,id=GH_USER \ | |
| --mount=type=secret,id=GH_TOKEN \ | |
| git clone https://$(cat /run/secrets/GH_USER):$(cat /run/secrets/GH_TOKEN)@github.com/leoncool23/DUCG_Modeler.git . | |
| # --- 3. 设置Python环境 --- | |
| # 安装 requirements.txt 文件中定义的所有依赖 | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # --- 4. 运行应用 --- | |
| # 暴露 Hugging Face Spaces 期望的标准端口 7860 | |
| EXPOSE 7860 | |
| # 使用 gunicorn 启动 Flask 应用。 | |
| # gunicorn 是一个生产级的 WSGI 服务器,比 Flask 自带的开发服务器更稳定。 | |
| # "--bind", "0.0.0.0:7860" 使应用可以从外部访问。 | |
| # "app:app" 指的是运行 app.py 文件中的 app 实例。 | |
| CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:7860", "app:app"] |