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