From a49f4c617da3ddcb37a2f438b083b960090ad42a Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 1 May 2026 16:29:46 +1000 Subject: [PATCH] fix: prevent tui rebuilding assets --- .dockerignore | 6 ++++++ Dockerfile | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index 542c96700e..41999f5ac6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,6 +9,12 @@ node_modules .venv **/.venv +# Built artifacts that are regenerated inside the image. Excluded so local +# rebuilds on the developer's machine don't invalidate the npm-install layer +# that now depends on the full ui-tui/packages/hermes-ink/ tree being present. +ui-tui/dist/ +ui-tui/packages/hermes-ink/dist/ + # CI/CD .github diff --git a/Dockerfile b/Dockerfile index 18177cc1ac..08a5b6a275 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,10 +28,26 @@ WORKDIR /opt/hermes # ---------- Layer-cached dependency install ---------- # Copy only package manifests first so npm install + Playwright are cached # unless the lockfiles themselves change. +# +# ui-tui/packages/hermes-ink/ is copied IN FULL (not just its manifests) +# because it is referenced as a `file:` workspace dependency from +# ui-tui/package.json. Copying the tree up front lets npm resolve the +# workspace to real content instead of stopping at a bare package.json. COPY package.json package-lock.json ./ COPY web/package.json web/package-lock.json web/ COPY ui-tui/package.json ui-tui/package-lock.json ui-tui/ -COPY ui-tui/packages/hermes-ink/package.json ui-tui/packages/hermes-ink/package-lock.json ui-tui/packages/hermes-ink/ +COPY ui-tui/packages/hermes-ink/ ui-tui/packages/hermes-ink/ + +# `npm_config_install_links=false` forces npm to install `file:` deps as +# symlinks (the npm 10+ default) even on Debian's older bundled npm 9.x, +# which defaults to `install-links=true` and installs file deps as *copies*. +# The host-side package-lock.json is generated with a newer npm that uses +# symlinks, so an install-as-copy produces a hidden node_modules/.package-lock.json +# that permanently disagrees with the root lock on the @hermes/ink entry. +# That disagreement trips the TUI launcher's `_tui_need_npm_install()` +# check on every startup and triggers a runtime `npm install` that then +# fails with EACCES (node_modules/ is root-owned from build time). +ENV npm_config_install_links=false RUN npm install --prefer-offline --no-audit && \ npx playwright install --with-deps chromium --only-shell && \ @@ -45,13 +61,7 @@ COPY --chown=hermes:hermes . . # Build browser dashboard and terminal UI assets. RUN cd web && npm run build && \ - cd ../ui-tui && npm run build && \ - rm -rf node_modules/@hermes/ink && \ - rm -rf packages/hermes-ink/node_modules && \ - cp -R packages/hermes-ink node_modules/@hermes/ink && \ - npm install --omit=dev --prefer-offline --no-audit --prefix node_modules/@hermes/ink && \ - rm -rf node_modules/@hermes/ink/node_modules/react && \ - node --input-type=module -e "await import('@hermes/ink')" + cd ../ui-tui && npm run build # ---------- Permissions ---------- # Make install dir world-readable so any HERMES_UID can read it at runtime.