Spaces:
Paused
Paused
Update Dockerfile
Browse files1234533 unmodified lines394041424344454647484950515224 unmodified lines77787980818283146 unmodified lines230231232233234235236100 unmodified lines33733833934034134234379 unmodified lines4234244254264274284297 unmodified lines43743843944044144244375 unmodified lines51952052152252352452552631 unmodified lines558559560561562563564# ============================================================# Hermes Agent β Self-contained HF Spaces deployment (Stable v5.4)# Single Dockerfile: Gateway + Dashboard + Chat WebUI + Router## HOW TO DEPLOY:33 unmodified lines&& ( [ -f /root/.local/bin/hf ] && mv /root/.local/bin/hf /usr/local/bin/hf || true ) \&& chmod +x /usr/local/bin/hf || true# ββ Clone Hermes WebUI & Patch hardcoded localhost URLs at Build Time ββ# Moving patching to the build phase cuts startup time from 5 minutes to near-instant!RUN git clone --depth 1 https://github.com/nesquena/hermes-webui.git /opt/hermes-webui \&& ( [ -f /opt/hermes-webui/requirements.txt ] \&& /opt/hermes/.venv/bin/pip install --no-cache-dir \-r /opt/hermes-webui/requirements.txt \|| true ) \&& python3 - <<'PYPATCH_BUILD'import os, reweb_dir = "/opt/hermes-webui"for root, dirs, files in os.walk(web_dir):24 unmodified linesprint(f"[build-patch] Successfully patched: {fpath}")except Exception:passPYPATCH_BUILD \&& chown -R hermes:hermes /opt/hermes-webui# ββ Node router deps ββββββββββββββββββββββββββββββββββββββββββ146 unmodified linesvar url = req.url || '/';var referer = req.headers.referer || '';// FIX: Robustly parse the URL using Node native API to get the string pathvar pathname = urlParser.parse(url).pathname || '/';// Route: /health check (public)100 unmodified linesres.setHeader('Set-Cookie', 'hm_scope=' + activeScope + cookieFlags);if (isDashboard) {// FIX: Keep URL completely intact when forwarding to the Dashboard. FastAPI is strictly// expecting the `/dashboard` prefix inside its own server paths.return proxy.web(req, res, { target: 'http://127.0.0.1:9119', changeOrigin: true });}79 unmodified linesfi# ββ 3. FIXED SQLITE INTEGRITY RECOVERY & WAL ENABLING βββββ# FIX: Fixed standard database integrity evaluation to prevent persistent re-wipe loops.echo "[boot] π©Ί Checking database integrity & enabling WAL mode..."python3 - <<'PY_SQLITE_RECOVER'import os, sqlite37 unmodified linescursor = conn.cursor()cursor.execute("PRAGMA integrity_check;")res = cursor.fetchone()# FIX: fetchone returns a tuple (e.g. ("ok",)). Checking res == "ok" always failed.if res and res == "ok":cursor.execute("PRAGMA journal_mode=WAL;")cursor.execute("PRAGMA synchronous=NORMAL;")75 unmodified linesmv "$TMP_ENV" "$ENV_FILE"chmod 600 "$ENV_FILE"# FIX: Export the updated API credentials to the system process environment on boot# so the Gateway automatically authenticates correctly without any 401 errors.if [ -f "$ENV_FILE" ]; thenset -o allexportsource "$ENV_FILE"31 unmodified linesfi# ββ 9. START SERVICES βββββββββββββββββββββββββββββββββββββββββ# FIX: Change execution directory to $HH so the processes correctly load configurations.cd "$HH"echo "[boot] π Starting Hermes Gateway (port 8642)..."1234533 unmodified lines3940414243444546474849505152535424 unmodified lines7980818283848586878889146 unmodified lines236237238239240241100 unmodified lines34234334434534634734879 unmodified lines4284294304314324337 unmodified lines44144244344444544675 unmodified lines52252352452552652731 unmodified lines559560561562563564# ============================================================# Hermes Agent β Self-contained HF Spaces deployment (Stable v5.5)# Single Dockerfile: Gateway + Dashboard + Chat WebUI + Router## HOW TO DEPLOY:33 unmodified lines&& ( [ -f /root/.local/bin/hf ] && mv /root/.local/bin/hf /usr/local/bin/hf || true ) \&& chmod +x /usr/local/bin/hf || true# ββ Clone Hermes WebUI ββββββββββββββββββββββββββββββββββββββββRUN git clone --depth 1 https://github.com/nesquena/hermes-webui.git /opt/hermes-webui \&& ( [ -f /opt/hermes-webui/requirements.txt ] \&& /opt/hermes/.venv/bin/pip install --no-cache-dir \-r /opt/hermes-webui/requirements.txt \|| true )# ββ Write build-time URL patch script βββββββββββββββββββββββββ# Writing to a clean temporary file completely bypasses Docker's "unterminated heredoc" issue!RUN cat << 'EOF' > /tmp/patch_webui.pyimport os, reweb_dir = "/opt/hermes-webui"for root, dirs, files in os.walk(web_dir):24 unmodified linesprint(f"[build-patch] Successfully patched: {fpath}")except Exception:passEOF# ββ Execute build-time patch and set directory permissions ββββRUN python3 /tmp/patch_webui.py \&& rm /tmp/patch_webui.py \&& chown -R hermes:hermes /opt/hermes-webui# ββ Node router deps ββββββββββββββββββββββββββββββββββββββββββ146 unmodified linesvar url = req.url || '/';var referer = req.headers.referer || '';var pathname = urlParser.parse(url).pathname || '/';// Route: /health check (public)100 unmodified linesres.setHeader('Set-Cookie', 'hm_scope=' + activeScope + cookieFlags);if (isDashboard) {// Keep URL completely intact when forwarding to the Dashboard. FastAPI is strictly// expecting the `/dashboard` prefix inside its own server paths.return proxy.web(req, res, { target: 'http://127.0.0.1:9119', changeOrigin: true });}79 unmodified linesfi# ββ 3. FIXED SQLITE INTEGRITY RECOVERY & WAL ENABLING βββββecho "[boot] π©Ί Checking database integrity & enabling WAL mode..."python3 - <<'PY_SQLITE_RECOVER'import os, sqlite37 unmodified linescursor = conn.cursor()cursor.execute("PRAGMA integrity_check;")res = cursor.fetchone()if res and res == "ok":cursor.execute("PRAGMA journal_mode=WAL;")cursor.execute("PRAGMA synchronous=NORMAL;")75 unmodified linesmv "$TMP_ENV" "$ENV_FILE"chmod 600 "$ENV_FILE"if [ -f "$ENV_FILE" ]; thenset -o allexportsource "$ENV_FILE"31 unmodified linesfi# ββ 9. START SERVICES βββββββββββββββββββββββββββββββββββββββββcd "$HH"echo "[boot] π Starting Hermes Gateway (port 8642)..."
Dockerfile+13-13