Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +3 -10
Dockerfile
CHANGED
|
@@ -8,24 +8,17 @@ WORKDIR /app
|
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends git
|
| 9 |
|
| 10 |
# --- 关键步骤:使用PAT克隆私有仓库 ---
|
| 11 |
-
# 从Hugging Face Secrets中获取GitHub用户名和PAT
|
| 12 |
-
# 注意:URL路径中的 'leoncool23/ducg-knowledge-editor' 是硬编码的
|
| 13 |
RUN --mount=type=secret,id=GH_USERNAME \
|
| 14 |
--mount=type=secret,id=GH_TOKEN \
|
| 15 |
git clone https://$(cat /run/secrets/GH_USERNAME):$(cat /run/secrets/GH_TOKEN)@github.com/leoncool23/ducg-knowledge-editor.git .
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
# --- 设置Python环境 ---
|
| 18 |
-
# 安装Python依赖
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
-
|
| 21 |
-
# 安装Gunicorn用于生产环境
|
| 22 |
RUN pip install gunicorn
|
| 23 |
|
| 24 |
# --- 运行应用 ---
|
| 25 |
-
# 暴露端口 (Hugging Face Spaces默认使用7860)
|
| 26 |
EXPOSE 7860
|
| 27 |
-
|
| 28 |
-
# 启动应用的命令
|
| 29 |
-
# app:app 指的是在 app.py 文件中名为 app 的Flask实例
|
| 30 |
-
# --timeout 120 增加超时时间,以防复杂操作中断
|
| 31 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|
|
|
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends git
|
| 9 |
|
| 10 |
# --- 关键步骤:使用PAT克隆私有仓库 ---
|
|
|
|
|
|
|
| 11 |
RUN --mount=type=secret,id=GH_USERNAME \
|
| 12 |
--mount=type=secret,id=GH_TOKEN \
|
| 13 |
git clone https://$(cat /run/secrets/GH_USERNAME):$(cat /run/secrets/GH_TOKEN)@github.com/leoncool23/ducg-knowledge-editor.git .
|
| 14 |
|
| 15 |
+
# --- 新增步骤:创建并授权持久化存储目录 ---
|
| 16 |
+
RUN mkdir -p /data && chown -R 1000:1000 /data
|
| 17 |
+
|
| 18 |
# --- 设置Python环境 ---
|
|
|
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
| 20 |
RUN pip install gunicorn
|
| 21 |
|
| 22 |
# --- 运行应用 ---
|
|
|
|
| 23 |
EXPOSE 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|