|
|
|
|
@@ -1,34 +1,52 @@
|
|
|
|
|
# 1. On récupère la version la plus récente d'UV
|
|
|
|
|
FROM ghcr.io/astral-sh/uv:latest AS uv_source
|
|
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
|
# Hermes Agent -- custom fork build
|
|
|
|
|
# Builds on top of official image + overlays our forked source from Gitea.
|
|
|
|
|
# Requires Docker BuildKit. Pass SSH agent for git clone:
|
|
|
|
|
# docker compose build hermes
|
|
|
|
|
# Or manually:
|
|
|
|
|
# DOCKER_BUILDKIT=1 docker build --ssh default -t hermes-agent:custom .
|
|
|
|
|
|
|
|
|
|
# 2. Image officielle Hermes Agent de NousResearch
|
|
|
|
|
# Contient déjà: Python, Node.js, npm, Playwright/Chromium, venv, tts_tool.py, etc.
|
|
|
|
|
# ---------- Base: official Hermes image (system deps, npm, uv, Playwright) ----------
|
|
|
|
|
FROM nousresearch/hermes-agent:latest
|
|
|
|
|
|
|
|
|
|
# ---------- System dependencies ----------
|
|
|
|
|
# The official hermes-agent image already has: git, curl, ffmpeg, python3,
|
|
|
|
|
# gcc, build-essential, openssh-client, procps, tini, ripgrep, docker-cli,
|
|
|
|
|
# libportaudio2, ca-certificates, etc.
|
|
|
|
|
# ---------- Overlay our forked source ----------
|
|
|
|
|
# Uses SSH agent forwarding from the build host (no key baked into image).
|
|
|
|
|
# --exclude node_modules/.venv keeps the base image's pre-built layers intact.
|
|
|
|
|
# Only the Python source, web UI source, and config change.
|
|
|
|
|
RUN --mount=type=ssh \
|
|
|
|
|
mkdir -p /root/.ssh && \
|
|
|
|
|
ssh-keyscan -p 2222 code.lazyworkhorse.net >> /root/.ssh/known_hosts 2>/dev/null && \
|
|
|
|
|
cd /tmp && \
|
|
|
|
|
GIT_SSH_COMMAND='ssh -p 2222 -o StrictHostKeyChecking=no' \
|
|
|
|
|
git clone --depth 1 --branch main \
|
|
|
|
|
git@code.lazyworkhorse.net:gortium/hermes-agent.git fork && \
|
|
|
|
|
rsync -a --delete fork/ /opt/hermes/ \
|
|
|
|
|
--exclude node_modules \
|
|
|
|
|
--exclude .venv \
|
|
|
|
|
--exclude .git && \
|
|
|
|
|
rm -rf /tmp/fork /root/.ssh/
|
|
|
|
|
|
|
|
|
|
# ---------- Rebuild web UI ----------
|
|
|
|
|
# Source files changed; node_modules (from base image) reused.
|
|
|
|
|
RUN cd /opt/hermes && npm run build
|
|
|
|
|
|
|
|
|
|
# ---------- Reinstall Python package (editable) ----------
|
|
|
|
|
# Picks up source changes from our fork.
|
|
|
|
|
RUN . /opt/hermes/.venv/bin/activate && \
|
|
|
|
|
uv pip install --no-cache-dir --no-deps -e /opt/hermes
|
|
|
|
|
|
|
|
|
|
# ---------- Extra system deps ----------
|
|
|
|
|
USER root
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
poppler-utils \
|
|
|
|
|
imagemagick \
|
|
|
|
|
texlive-latex-base \
|
|
|
|
|
texlive-latex-extra \
|
|
|
|
|
texlive-fonts-recommended \
|
|
|
|
|
texlive-xetex \
|
|
|
|
|
texlive-science && \
|
|
|
|
|
libportaudio2 ca-certificates poppler-utils imagemagick \
|
|
|
|
|
texlive-latex-base texlive-latex-extra texlive-fonts-recommended \
|
|
|
|
|
texlive-xetex texlive-science \
|
|
|
|
|
qemu-user-static binfmt-support emacs-nox && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# ---------- UV (hyperfast pip alternative) ----------
|
|
|
|
|
COPY --chmod=0755 --from=uv_source /uv /usr/local/bin/
|
|
|
|
|
|
|
|
|
|
WORKDIR /opt/hermes
|
|
|
|
|
|
|
|
|
|
# ---------- Extra Python deps ----------
|
|
|
|
|
RUN . /opt/hermes/.venv/bin/activate && \
|
|
|
|
|
uv pip install --no-cache-dir httpx
|
|
|
|
|
# ---------- UV ----------
|
|
|
|
|
COPY --chmod=0755 --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/
|
|
|
|
|
|
|
|
|
|
# ---------- Piper TTS ----------
|
|
|
|
|
RUN . /opt/hermes/.venv/bin/activate && \
|
|
|
|
|
@@ -41,7 +59,6 @@ base = '/opt/hermes/.venv/share/piper/voices'
|
|
|
|
|
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')
|
|
|
|
|
print('Piper voice downloaded')
|
|
|
|
|
PYEOF
|
|
|
|
|
|
|
|
|
|
# ---------- Install Himalaya email CLI ----------
|
|
|
|
|
@@ -61,11 +78,47 @@ PYEOF
|
|
|
|
|
# ---------- Install himalaya-ro wrapper ----------
|
|
|
|
|
COPY --chmod=0755 himalaya-ro.sh /usr/local/bin/himalaya-ro
|
|
|
|
|
|
|
|
|
|
# ---------- Patch tts_tool.py: remplacer Edge TTS par Piper ----------
|
|
|
|
|
# Edge TTS appelle les serveurs Microsoft — on ne veut jamais ça.
|
|
|
|
|
# Piper roule localement sur CPU, aucun cloud, aucune donnée qui sort.
|
|
|
|
|
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
|
|
|
|
|
# ---------- Install 7-Zip for CHM extraction ----------
|
|
|
|
|
RUN /opt/hermes/.venv/bin/python3 /dev/stdin << 'PYEOF'
|
|
|
|
|
import urllib.request, tarfile, os, shutil, re, subprocess
|
|
|
|
|
|
|
|
|
|
# Scrape 7-zip.org for latest Linux x64 binary
|
|
|
|
|
url = 'https://7-zip.org/download.html'
|
|
|
|
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
|
|
|
|
r = urllib.request.urlopen(req, timeout=15)
|
|
|
|
|
html = r.read().decode()
|
|
|
|
|
|
|
|
|
|
links = re.findall(r'href="(a/7z[\d]+-linux-x64\.tar\.xz)"', html)
|
|
|
|
|
if not links:
|
|
|
|
|
raise RuntimeError("Could not find 7z download link")
|
|
|
|
|
|
|
|
|
|
dl_url = f'https://7-zip.org/{links[0]}'
|
|
|
|
|
print(f'Downloading 7z from {dl_url}...')
|
|
|
|
|
req = urllib.request.Request(dl_url, headers={'User-Agent': 'Mozilla/5.0'})
|
|
|
|
|
r = urllib.request.urlopen(req, timeout=30)
|
|
|
|
|
data = r.read()
|
|
|
|
|
|
|
|
|
|
with open('/tmp/7z.tar.xz', 'wb') as f:
|
|
|
|
|
f.write(data)
|
|
|
|
|
|
|
|
|
|
subprocess.run(['tar', '-xJf', '/tmp/7z.tar.xz', '-C', '/tmp/'], check=True)
|
|
|
|
|
|
|
|
|
|
for root, dirs, files in os.walk('/tmp'):
|
|
|
|
|
for f in files:
|
|
|
|
|
if f == '7zz':
|
|
|
|
|
src = os.path.join(root, f)
|
|
|
|
|
shutil.move(src, '/usr/local/bin/7zz')
|
|
|
|
|
os.chmod('/usr/local/bin/7zz', 0o755)
|
|
|
|
|
print(f'7zz installed from {src}')
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
os.remove('/tmp/7z.tar.xz')
|
|
|
|
|
|
|
|
|
|
# Verify
|
|
|
|
|
r = subprocess.run(['/usr/local/bin/7zz'], capture_output=True, text=True)
|
|
|
|
|
print(f'7-Zip {r.stdout.strip()[:60]}')
|
|
|
|
|
PYEOF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Runtime ----------
|
|
|
|
|
USER hermes
|
|
|
|
|
@@ -74,9 +127,8 @@ ENV PATH="/opt/data/.local/bin:${PATH}"
|
|
|
|
|
# Point browser tool to Playwright's Chromium (already in base image)
|
|
|
|
|
ENV CHROME_EXECUTABLE=/opt/hermes/.playwright/chromium/chrome-linux/chrome
|
|
|
|
|
|
|
|
|
|
VOLUME [ "/opt/data" ]
|
|
|
|
|
# Ensure tools directory and toolsets.py are writable by the hermes runtime user
|
|
|
|
|
# so custom tools can be injected from the persistent volume at startup.
|
|
|
|
|
RUN chown -R hermes:hermes /opt/hermes/tools /opt/hermes/toolsets.py
|
|
|
|
|
|
|
|
|
|
# Startup permission fix + config generation + TTS patch
|
|
|
|
|
COPY --chmod=0755 fix-permissions.sh /opt/hermes/fix-permissions.sh
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT [ "/usr/bin/tini", "-g", "--", "/opt/hermes/fix-permissions.sh" ]
|
|
|
|
|
VOLUME [ "/opt/data" ]
|