Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +35 -50
Dockerfile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
ARG HERMES_AGENT_VERSION=latest
|
| 4 |
FROM nousresearch/hermes-agent:${HERMES_AGENT_VERSION}
|
| 5 |
|
| 6 |
USER root
|
| 7 |
|
|
|
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
ca-certificates \
|
| 10 |
curl \
|
|
@@ -34,8 +34,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 34 |
&& (apt-get install -y --no-install-recommends libasound2 2>/dev/null \
|
| 35 |
|| apt-get install -y --no-install-recommends libasound2t64 2>/dev/null \
|
| 36 |
|| true) \
|
| 37 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
"jupyterlab>=4.0,<5" \
|
| 40 |
"tornado>=6.4" \
|
| 41 |
"ipywidgets>=8.1" \
|
|
@@ -43,6 +45,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 43 |
&& chmod 0440 /etc/sudoers.d/hermes \
|
| 44 |
&& /usr/sbin/visudo -cf /etc/sudoers.d/hermes
|
| 45 |
|
|
|
|
| 46 |
COPY --chown=hermes:hermes start.sh /opt/huggingmes/start.sh
|
| 47 |
COPY --chown=hermes:hermes health-server.js /opt/huggingmes/health-server.js
|
| 48 |
COPY --chown=hermes:hermes cloudflare-proxy-setup.py /opt/huggingmes/cloudflare-proxy-setup.py
|
|
@@ -55,65 +58,47 @@ RUN chmod +x \
|
|
| 55 |
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 56 |
/opt/huggingmes/cloudflare-keepalive-setup.py
|
| 57 |
|
| 58 |
-
#
|
| 59 |
RUN python3 - <<'PY'
|
| 60 |
import sys
|
| 61 |
try:
|
| 62 |
from pathlib import Path
|
| 63 |
-
|
| 64 |
p = Path("/opt/hermes/hermes_cli/kanban_db.py")
|
| 65 |
-
if
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
'
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
' conn.execute(\n'
|
| 84 |
-
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 85 |
-
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 86 |
-
' )\n'
|
| 87 |
-
' except Exception:\n'
|
| 88 |
-
' pass'
|
| 89 |
-
)
|
| 90 |
-
|
| 91 |
-
if old not in src:
|
| 92 |
-
print("kanban patch: pattern not found, may be fixed upstream, skipping")
|
| 93 |
-
sys.exit(0)
|
| 94 |
-
|
| 95 |
-
p.write_text(src.replace(old, new), encoding="utf-8")
|
| 96 |
-
print("kanban patch: applied")
|
| 97 |
except Exception as e:
|
| 98 |
-
print(f"kanban patch
|
| 99 |
PY
|
| 100 |
|
| 101 |
-
#
|
| 102 |
-
RUN echo 'export PATH="/opt/hermes/.venv/bin:/
|
|
|
|
| 103 |
|
| 104 |
-
#
|
| 105 |
-
|
| 106 |
-
# ════════════════════════════════════════════════════════════════
|
| 107 |
-
ENV HERMES_HOME=/home/hermes \
|
| 108 |
HUGGINGMES_APP_DIR=/opt/huggingmes \
|
| 109 |
HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
|
| 110 |
PYTHONUNBUFFERED=1 \
|
| 111 |
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
|
| 112 |
|
| 113 |
-
ENTRYPOINT ["/bin/bash", "/opt/huggingmes/start.sh"]
|
| 114 |
-
USER root
|
| 115 |
-
|
| 116 |
EXPOSE 7861
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
| 1 |
+
# 采用官方给定的核心底座
|
|
|
|
| 2 |
ARG HERMES_AGENT_VERSION=latest
|
| 3 |
FROM nousresearch/hermes-agent:${HERMES_AGENT_VERSION}
|
| 4 |
|
| 5 |
USER root
|
| 6 |
|
| 7 |
+
# 1. 完整保留原项目的全部系统依赖
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
ca-certificates \
|
| 10 |
curl \
|
|
|
|
| 34 |
&& (apt-get install -y --no-install-recommends libasound2 2>/dev/null \
|
| 35 |
|| apt-get install -y --no-install-recommends libasound2t64 2>/dev/null \
|
| 36 |
|| true) \
|
| 37 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 38 |
+
|
| 39 |
+
# 2. 将 JupyterLab 注入到虚拟环境中以驱动原项目的 Terminal 终端
|
| 40 |
+
RUN uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir \
|
| 41 |
"jupyterlab>=4.0,<5" \
|
| 42 |
"tornado>=6.4" \
|
| 43 |
"ipywidgets>=8.1" \
|
|
|
|
| 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
|
|
|
|
| 58 |
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 59 |
/opt/huggingmes/cloudflare-keepalive-setup.py
|
| 60 |
|
| 61 |
+
# 4. 保留原项目看板数据库迁移幂等补丁
|
| 62 |
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 |
+
src = p.read_text(encoding="utf-8", errors="replace")
|
| 69 |
+
sentinel = "# huggingmes: idempotent-alter"
|
| 70 |
+
if sentinel not in src:
|
| 71 |
+
old = (' conn.execute(\n'
|
| 72 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 73 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 74 |
+
' )')
|
| 75 |
+
new = (f' try: {sentinel}\n'
|
| 76 |
+
' conn.execute(\n'
|
| 77 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 78 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 79 |
+
' )\n'
|
| 80 |
+
' except Exception:\n'
|
| 81 |
+
' pass')
|
| 82 |
+
if old in src:
|
| 83 |
+
p.write_text(src.replace(old, new), encoding="utf-8")
|
| 84 |
+
print("kanban patch: applied")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
except Exception as e:
|
| 86 |
+
print(f"kanban patch error: {e}", file=sys.stderr)
|
| 87 |
PY
|
| 88 |
|
| 89 |
+
# 5. 坚决维持原项目持久化存储桶挂载路径 /opt/data
|
| 90 |
+
RUN echo 'export PATH="/opt/hermes/.venv/bin:/opt/data/.local/bin:$PATH"' \
|
| 91 |
+
> /etc/profile.d/hermes-venv.sh
|
| 92 |
|
| 93 |
+
# 环境变量修正:完全对齐官方与魔改共存的工作空间路径
|
| 94 |
+
ENV HERMES_HOME=/opt/data \
|
|
|
|
|
|
|
| 95 |
HUGGINGMES_APP_DIR=/opt/huggingmes \
|
| 96 |
HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
|
| 97 |
PYTHONUNBUFFERED=1 \
|
| 98 |
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
|
| 99 |
|
|
|
|
|
|
|
|
|
|
| 100 |
EXPOSE 7861
|
| 101 |
|
| 102 |
+
# 以 root 入口进行底层隔离、挂载刷新与锁清洗,随后平滑切回降权用户空间
|
| 103 |
+
USER root
|
| 104 |
+
CMD ["/opt/huggingmes/start.sh"]
|