Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +44 -24
Dockerfile
CHANGED
|
@@ -45,7 +45,7 @@ RUN uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir \
|
|
| 45 |
&& chmod 0440 /etc/sudoers.d/hermes \
|
| 46 |
&& /usr/sbin/visudo -cf /etc/sudoers.d/hermes
|
| 47 |
|
| 48 |
-
# 3. 复制魔改项目的全部核心组件
|
| 49 |
COPY --chown=hermes:hermes start.sh /opt/huggingmes/start.sh
|
| 50 |
COPY --chown=hermes:hermes health-server.js /opt/huggingmes/health-server.js
|
| 51 |
COPY --chown=hermes:hermes cloudflare-proxy-setup.py /opt/huggingmes/cloudflare-proxy-setup.py
|
|
@@ -53,7 +53,9 @@ COPY --chown=hermes:hermes cloudflare-keepalive-setup.py /opt/huggingmes/cloudfl
|
|
| 53 |
COPY --chown=hermes:hermes env-builder.html /opt/huggingmes/env-builder.html
|
| 54 |
COPY --chown=hermes:hermes env-builder.js /opt/huggingmes/env-builder.js
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
/opt/huggingmes/start.sh \
|
| 58 |
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 59 |
/opt/huggingmes/cloudflare-keepalive-setup.py
|
|
@@ -63,27 +65,42 @@ RUN python3 - <<'PY'
|
|
| 63 |
import sys
|
| 64 |
try:
|
| 65 |
from pathlib import Path
|
|
|
|
| 66 |
p = Path("/opt/hermes/hermes_cli/kanban_db.py")
|
| 67 |
-
if p.exists():
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
except Exception as e:
|
| 86 |
-
print(f"kanban patch error
|
| 87 |
PY
|
| 88 |
|
| 89 |
# 5. 坚决维持原项目持久化存储桶挂载路径 /opt/data
|
|
@@ -99,6 +116,9 @@ ENV HERMES_HOME=/opt/data \
|
|
| 99 |
|
| 100 |
EXPOSE 7861
|
| 101 |
|
| 102 |
-
#
|
| 103 |
-
|
| 104 |
-
CMD
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
&& chmod 0440 /etc/sudoers.d/hermes \
|
| 46 |
&& /usr/sbin/visudo -cf /etc/sudoers.d/hermes
|
| 47 |
|
| 48 |
+
# 3. 复制魔改项目的全部核心组件并【强制洗刷换行符】
|
| 49 |
COPY --chown=hermes:hermes start.sh /opt/huggingmes/start.sh
|
| 50 |
COPY --chown=hermes:hermes health-server.js /opt/huggingmes/health-server.js
|
| 51 |
COPY --chown=hermes:hermes cloudflare-proxy-setup.py /opt/huggingmes/cloudflare-proxy-setup.py
|
|
|
|
| 53 |
COPY --chown=hermes:hermes env-builder.html /opt/huggingmes/env-builder.html
|
| 54 |
COPY --chown=hermes:hermes env-builder.js /opt/huggingmes/env-builder.js
|
| 55 |
|
| 56 |
+
# CRITICAL FIX: 强刷去除可能由于 Windows 编辑带来的 \r 换行符污染
|
| 57 |
+
RUN sed -i 's/\r$//' /opt/huggingmes/start.sh && \
|
| 58 |
+
chmod +x \
|
| 59 |
/opt/huggingmes/start.sh \
|
| 60 |
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 61 |
/opt/huggingmes/cloudflare-keepalive-setup.py
|
|
|
|
| 65 |
import sys
|
| 66 |
try:
|
| 67 |
from pathlib import Path
|
| 68 |
+
|
| 69 |
p = Path("/opt/hermes/hermes_cli/kanban_db.py")
|
| 70 |
+
if not p.exists():
|
| 71 |
+
print("kanban patch: file not found, skipping")
|
| 72 |
+
sys.exit(0)
|
| 73 |
+
|
| 74 |
+
src = p.read_text(encoding="utf-8", errors="replace")
|
| 75 |
+
sentinel = "# huggingmes: idempotent-alter"
|
| 76 |
+
if sentinel in src:
|
| 77 |
+
print("kanban patch: already applied, skipping")
|
| 78 |
+
sys.exit(0)
|
| 79 |
+
|
| 80 |
+
old = (
|
| 81 |
+
' conn.execute(\n'
|
| 82 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 83 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 84 |
+
' )'
|
| 85 |
+
)
|
| 86 |
+
new = (
|
| 87 |
+
f' try: {sentinel}\n'
|
| 88 |
+
' conn.execute(\n'
|
| 89 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 90 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 91 |
+
' )\n'
|
| 92 |
+
' except Exception:\n'
|
| 93 |
+
' pass'
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
if old not in src:
|
| 97 |
+
print("kanban patch: pattern not found, may be fixed upstream, skipping")
|
| 98 |
+
sys.exit(0)
|
| 99 |
+
|
| 100 |
+
p.write_text(src.replace(old, new), encoding="utf-8")
|
| 101 |
+
print("kanban patch: applied")
|
| 102 |
except Exception as e:
|
| 103 |
+
print(f"kanban patch: error ({e}), skipping", file=sys.stderr)
|
| 104 |
PY
|
| 105 |
|
| 106 |
# 5. 坚决维持原项目持久化存储桶挂载路径 /opt/data
|
|
|
|
| 116 |
|
| 117 |
EXPOSE 7861
|
| 118 |
|
| 119 |
+
# 维持 HF Spaces 健康检查探针
|
| 120 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s \
|
| 121 |
+
CMD curl -fsS http://localhost:7861/health || exit 1
|
| 122 |
+
|
| 123 |
+
# 以 root 入口显式通过 bash 驱动,防止底层 s6 管理器因不可见标识符再次 exec 失败
|
| 124 |
+
CMD ["/bin/bash", "/opt/huggingmes/start.sh"]
|