2026-05-09 02:38:23 +00:00
|
|
|
# 1. On récupère la version la plus récente d'UV
|
|
|
|
|
FROM ghcr.io/astral-sh/uv:latest AS uv_source
|
|
|
|
|
|
|
|
|
|
# 2. Image de base stable
|
|
|
|
|
FROM debian:stable-slim
|
2026-05-05 01:42:55 +00:00
|
|
|
|
|
|
|
|
# Disable Python stdout buffering to ensure logs are printed immediately
|
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
|
|
# Install system dependencies in one layer, clear APT cache
|
|
|
|
|
# tini reaps orphaned zombie processes (MCP stdio subprocesses, git, bun, etc.)
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
|
apt-get install -y --no-install-recommends \
|
2026-05-09 02:38:23 +00:00
|
|
|
build-essential python3 ripgrep ffmpeg gcc python3-dev libffi-dev procps git openssh-client docker-cli tini \
|
2026-05-05 01:42:55 +00:00
|
|
|
curl poppler-utils imagemagick \
|
|
|
|
|
texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-xetex texlive-science \
|
|
|
|
|
qemu-user-static binfmt-support qemu-user-binfmt \
|
|
|
|
|
emacs-nox \
|
2026-05-09 14:14:52 +00:00
|
|
|
libportaudio2 \
|
|
|
|
|
ca-certificates && \
|
2026-05-05 01:42:55 +00:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2026-05-09 02:38:23 +00:00
|
|
|
# Création de l'utilisateur 'hermes' directement avec les bons accès
|
2026-05-05 01:42:55 +00:00
|
|
|
RUN useradd -u 10000 -m -d /opt/data hermes
|
|
|
|
|
|
2026-05-09 02:38:23 +00:00
|
|
|
# Copie d'uv (dernière version)
|
|
|
|
|
COPY --chmod=0755 --from=uv_source /uv /usr/local/bin/
|
2026-05-05 01:42:55 +00:00
|
|
|
|
|
|
|
|
WORKDIR /opt/hermes
|
|
|
|
|
|
2026-05-09 02:38:23 +00:00
|
|
|
# On donne la propriété du dossier de travail à l'utilisateur hermes
|
|
|
|
|
RUN chown hermes:hermes /opt/hermes
|
2026-05-05 01:42:55 +00:00
|
|
|
|
2026-05-09 04:09:57 +00:00
|
|
|
# ---------- Hermes venv ----------
|
2026-05-09 02:38:23 +00:00
|
|
|
# Passer immédiatement sous l'utilisateur hermes pour tout le reste du build
|
|
|
|
|
USER hermes
|
2026-05-05 01:42:55 +00:00
|
|
|
|
|
|
|
|
# ---------- Source code ----------
|
2026-05-09 02:38:23 +00:00
|
|
|
# On copie tout le projet d'un coup sans assumer la présence de fichiers de lock spécifiques
|
2026-05-05 01:42:55 +00:00
|
|
|
COPY --chown=hermes:hermes . .
|
|
|
|
|
|
2026-05-09 13:41:37 +00:00
|
|
|
# ---------- Python virtualenv avec Piper TTS ----------
|
2026-05-05 01:42:55 +00:00
|
|
|
RUN uv venv && \
|
2026-05-09 17:37:32 +00:00
|
|
|
uv pip install --no-cache-dir hermes-agent piper-tts sounddevice numpy faster-whisper
|
2026-05-05 01:42:55 +00:00
|
|
|
|
2026-05-09 15:21:49 +00:00
|
|
|
# ---------- Télécharger la voix Piper Ryan (high quality) ----------
|
2026-05-09 13:41:37 +00:00
|
|
|
RUN mkdir -p /opt/hermes/.venv/share/piper/voices && \
|
2026-05-09 15:21:49 +00:00
|
|
|
/opt/hermes/.venv/bin/python3 /dev/stdin << 'PYEOF'
|
2026-05-09 13:41:37 +00:00
|
|
|
import urllib.request
|
|
|
|
|
base = '/opt/hermes/.venv/share/piper/voices'
|
2026-05-09 15:21:49 +00:00
|
|
|
url = 'https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/ryan/high/en_US-ryan-high.onnx'
|
|
|
|
|
urllib.request.urlretrieve(url, base + '/en_US-ryan-high.onnx')
|
|
|
|
|
urllib.request.urlretrieve(url + '.json', base + '/en_US-ryan-high.onnx.json')
|
2026-05-09 14:09:50 +00:00
|
|
|
PYEOF
|
2026-05-09 14:28:35 +00:00
|
|
|
|
2026-05-09 17:37:32 +00:00
|
|
|
# ---------- Patch tts_tool.py: replace Edge TTS fallback with Piper ----------
|
|
|
|
|
# Edge TTS calls out to Microsoft servers — we never want that.
|
|
|
|
|
# Piper runs locally on CPU, no cloud, no data leaving the machine.
|
|
|
|
|
# hermes-agent is installed from pip so tools/tts_tool.py exists in the venv.
|
|
|
|
|
COPY patch_tts_tool.py /tmp/patch_tts_tool.py
|
|
|
|
|
RUN /opt/hermes/.venv/bin/python3 /tmp/patch_tts_tool.py && rm /tmp/patch_tts_tool.py
|
|
|
|
|
|
2026-05-09 15:50:29 +00:00
|
|
|
# ---------- Patch atomic writes to preserve file permissions ----------
|
|
|
|
|
# Fixes https://github.com/NousResearch/hermes-agent/issues/14181
|
|
|
|
|
# tempfile.mkstemp() creates files as 0600; os.replace() preserves that mode,
|
|
|
|
|
# so group-readable files silently collapse to owner-private 0600.
|
|
|
|
|
# This affects: skills, sessions, memories, and any file written atomically.
|
|
|
|
|
RUN /opt/hermes/.venv/bin/python3 /dev/stdin << 'PYEOF'
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
|
("/opt/hermes/tools/skill_manager_tool.py", [
|
|
|
|
|
("# Restore existing file mode if present", True), # already patched
|
|
|
|
|
]),
|
|
|
|
|
("/opt/hermes/tools/skills_sync.py", [
|
|
|
|
|
("# Restore existing file mode if present", True), # already patched
|
|
|
|
|
]),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for fpath, checks in patches:
|
|
|
|
|
if not os.path.exists(fpath):
|
|
|
|
|
print(f"SKIP {fpath} (not found)")
|
|
|
|
|
continue
|
|
|
|
|
with open(fpath) as f:
|
|
|
|
|
code = f.read()
|
|
|
|
|
all_ok = all(marker in code for marker, _ in checks)
|
|
|
|
|
if all_ok:
|
|
|
|
|
print(f"OK {fpath} (already patched)")
|
|
|
|
|
continue
|
|
|
|
|
print(f"PATCH {fpath}")
|
|
|
|
|
# _atomic_write_text in skill_manager_tool.py
|
|
|
|
|
code = code.replace(
|
|
|
|
|
" os.replace(temp_path, file_path)",
|
|
|
|
|
" if file_path.exists():\n"
|
|
|
|
|
" existing_mode = file_path.stat().st_mode\n"
|
|
|
|
|
" os.chmod(temp_path, existing_mode)\n"
|
|
|
|
|
" os.replace(temp_path, file_path)",
|
|
|
|
|
)
|
|
|
|
|
# _write_manifest in skills_sync.py
|
|
|
|
|
code = code.replace(
|
|
|
|
|
" os.replace(tmp_path, MANIFEST_FILE)",
|
|
|
|
|
" if MANIFEST_FILE.exists():\n"
|
|
|
|
|
" existing_mode = MANIFEST_FILE.stat().st_mode\n"
|
|
|
|
|
" os.chmod(tmp_path, existing_mode)\n"
|
|
|
|
|
" os.replace(tmp_path, MANIFEST_FILE)",
|
|
|
|
|
)
|
|
|
|
|
with open(fpath, 'w') as f:
|
|
|
|
|
f.write(code)
|
|
|
|
|
print(f"DONE {fpath}")
|
|
|
|
|
PYEOF
|
|
|
|
|
|
2026-05-05 01:42:55 +00:00
|
|
|
# ---------- Runtime ----------
|
|
|
|
|
ENV HERMES_HOME=/opt/data
|
|
|
|
|
ENV PATH="/opt/data/.local/bin:${PATH}"
|
2026-05-09 02:38:23 +00:00
|
|
|
|
2026-05-05 01:42:55 +00:00
|
|
|
VOLUME [ "/opt/data" ]
|
2026-05-09 02:38:23 +00:00
|
|
|
|
2026-05-09 16:04:32 +00:00
|
|
|
# Copie du script de réparation des permissions (lancement au démarrage)
|
|
|
|
|
COPY --chmod=0755 fix-permissions.sh /opt/hermes/fix-permissions.sh
|
|
|
|
|
|
2026-05-09 02:38:23 +00:00
|
|
|
# Le conteneur tourne de manière ultra-sécurisée sous l'utilisateur hermes dès le départ
|
2026-05-09 16:04:32 +00:00
|
|
|
# fix-permissions.sh chown les répertoires critiques avant de chaîner vers entrypoint.sh
|
|
|
|
|
ENTRYPOINT [ "/usr/bin/tini", "-g", "--", "/opt/hermes/fix-permissions.sh" ]
|