Spaces:
Sleeping
Sleeping
| # 使用官方Python 3.9 slim镜像 | |
| FROM python:3.9-slim | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # --- 准备工作:安装git --- | |
| RUN apt-get update && apt-get install -y --no-install-recommends git | |
| # --- 关键步骤:使用PAT克隆私有仓库 --- | |
| # 从Hugging Face Secrets中获取GitHub用户名和PAT | |
| # 注意:URL路径中的 'leoncool23' 是硬编码的,必须是您的真实用户名 | |
| RUN --mount=type=secret,id=GH_USERNAME \ | |
| --mount=type=secret,id=GH_TOKEN \ | |
| git clone https://$(cat /run/secrets/GH_USERNAME):$(cat /run/secrets/GH_TOKEN)@github.com/leoncool23/ducg_web_update.git . | |
| # --- 设置Python环境 --- | |
| # 安装Python依赖 | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 安装Gunicorn用于生产环境 | |
| RUN pip install gunicorn | |
| # --- 运行应用 --- | |
| # 暴露端口 (Hugging Face Spaces通常使用7860) | |
| EXPOSE 7860 | |
| # 启动应用的命令 (已修正IP地址中的空格) | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"] | |