Spaces:
Paused
Paused
Upload Dockerfile.txt
Browse files- Dockerfile.txt +121 -0
Dockerfile.txt
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HuggingMes - Hermes Agent Gateway for Hugging Face Spaces
|
| 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 \
|
| 11 |
+
jq \
|
| 12 |
+
sudo \
|
| 13 |
+
python3 \
|
| 14 |
+
python3-venv \
|
| 15 |
+
python3-pip \
|
| 16 |
+
chromium \
|
| 17 |
+
dbus \
|
| 18 |
+
dbus-x11 \
|
| 19 |
+
libnss3 \
|
| 20 |
+
libatk1.0-0 \
|
| 21 |
+
libatk-bridge2.0-0 \
|
| 22 |
+
libdrm2 \
|
| 23 |
+
libgbm1 \
|
| 24 |
+
libxcomposite1 \
|
| 25 |
+
libxdamage1 \
|
| 26 |
+
libxrandr2 \
|
| 27 |
+
libxkbcommon0 \
|
| 28 |
+
libx11-6 \
|
| 29 |
+
libxext6 \
|
| 30 |
+
libxfixes3 \
|
| 31 |
+
fonts-dejavu-core \
|
| 32 |
+
fonts-liberation \
|
| 33 |
+
fonts-noto-color-emoji \
|
| 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 |
+
&& uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir \
|
| 39 |
+
"jupyterlab>=4.0,<5" \
|
| 40 |
+
"tornado>=6.4" \
|
| 41 |
+
"ipywidgets>=8.1" \
|
| 42 |
+
&& printf 'hermes ALL=(ALL) NOPASSWD: ALL\n' > /etc/sudoers.d/hermes \
|
| 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
|
| 49 |
+
COPY --chown=hermes:hermes cloudflare-keepalive-setup.py /opt/huggingmes/cloudflare-keepalive-setup.py
|
| 50 |
+
COPY --chown=hermes:hermes env-builder.html /opt/huggingmes/env-builder.html
|
| 51 |
+
COPY --chown=hermes:hermes env-builder.js /opt/huggingmes/env-builder.js
|
| 52 |
+
|
| 53 |
+
RUN chmod +x \
|
| 54 |
+
/opt/huggingmes/start.sh \
|
| 55 |
+
/opt/huggingmes/cloudflare-proxy-setup.py \
|
| 56 |
+
/opt/huggingmes/cloudflare-keepalive-setup.py
|
| 57 |
+
|
| 58 |
+
# Patch kanban migration: wrap ALTER TABLE ADD COLUMN in try/except so a
|
| 59 |
+
# persisted DB with the column already present doesn't crash the gateway.
|
| 60 |
+
# Entire block wrapped in try/except — skips silently if Hermes fixes this
|
| 61 |
+
# upstream or the file structure changes.
|
| 62 |
+
RUN python3 - <<'PY'
|
| 63 |
+
import sys
|
| 64 |
+
try:
|
| 65 |
+
from pathlib import Path
|
| 66 |
+
|
| 67 |
+
p = Path("/opt/hermes/hermes_cli/kanban_db.py")
|
| 68 |
+
if not p.exists():
|
| 69 |
+
print("kanban patch: file not found, skipping")
|
| 70 |
+
sys.exit(0)
|
| 71 |
+
|
| 72 |
+
src = p.read_text(encoding="utf-8", errors="replace")
|
| 73 |
+
sentinel = "# huggingmes: idempotent-alter"
|
| 74 |
+
if sentinel in src:
|
| 75 |
+
print("kanban patch: already applied, skipping")
|
| 76 |
+
sys.exit(0)
|
| 77 |
+
|
| 78 |
+
old = (
|
| 79 |
+
' conn.execute(\n'
|
| 80 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 81 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 82 |
+
' )'
|
| 83 |
+
)
|
| 84 |
+
new = (
|
| 85 |
+
f' try: {sentinel}\n'
|
| 86 |
+
' conn.execute(\n'
|
| 87 |
+
' "ALTER TABLE tasks ADD COLUMN consecutive_failures "\n'
|
| 88 |
+
' "INTEGER NOT NULL DEFAULT 0"\n'
|
| 89 |
+
' )\n'
|
| 90 |
+
' except Exception:\n'
|
| 91 |
+
' pass'
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
if old not in src:
|
| 95 |
+
print("kanban patch: pattern not found, may be fixed upstream, skipping")
|
| 96 |
+
sys.exit(0)
|
| 97 |
+
|
| 98 |
+
p.write_text(src.replace(old, new), encoding="utf-8")
|
| 99 |
+
print("kanban patch: applied")
|
| 100 |
+
except Exception as e:
|
| 101 |
+
print(f"kanban patch: error ({e}), skipping", file=sys.stderr)
|
| 102 |
+
PY
|
| 103 |
+
|
| 104 |
+
# Ensure hermes CLI is discoverable in ALL shell types (login, interactive,
|
| 105 |
+
# non-interactive). /etc/profile.d/ is sourced by login shells after /etc/profile
|
| 106 |
+
# resets PATH, so this survives even full environment resets.
|
| 107 |
+
RUN echo 'export PATH="/opt/hermes/.venv/bin:/opt/data/.local/bin:$PATH"' \
|
| 108 |
+
> /etc/profile.d/hermes-venv.sh
|
| 109 |
+
|
| 110 |
+
ENV HERMES_HOME=/opt/data \
|
| 111 |
+
HUGGINGMES_APP_DIR=/opt/huggingmes \
|
| 112 |
+
HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
|
| 113 |
+
PYTHONUNBUFFERED=1 \
|
| 114 |
+
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
|
| 115 |
+
|
| 116 |
+
EXPOSE 7861
|
| 117 |
+
|
| 118 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s \
|
| 119 |
+
CMD curl -fsS http://localhost:7861/health || exit 1
|
| 120 |
+
|
| 121 |
+
CMD ["/opt/huggingmes/start.sh"]
|