The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
perf(docker): cache the Webapp's dependency install in its own layer
unsupportedpastels51c8cba02408
diff --git a/Dockerfile b/Dockerfileindex 1ca25d1732f..779964df82f 100644--- a/Dockerfile+++ b/Dockerfile@@ -327,9 +327,15 @@ RUN node scripts/build/tui.mjs --source /opt/hermes --out /opt/products/tui && \# own so Desktop changes leave the TUI and dashboard layers cached.FROM runtime_base AS webapp_buildCOPY package.json package-lock.json .npmrc ./-COPY apps/ apps/+COPY apps/desktop/package.json apps/desktop/+COPY apps/desktop/scripts/build-webapp.mjs apps/desktop/scripts/+COPY apps/shared/package.json apps/shared/COPY scripts/build/*.mjs scripts/build/ENV npm_config_install_links=false+# Dependencies first, keyed only by the manifests and the recipe, so a source+# change reuses this layer and the build below reuses its install.+RUN node apps/desktop/scripts/build-webapp.mjs --deps-only+COPY apps/ apps/RUN node apps/desktop/scripts/build-webapp.mjsFROM python_deps AS runtimediff --git a/apps/desktop/scripts/build-webapp.mjs b/apps/desktop/scripts/build-webapp.mjsindex d851524adfb..80468ecc217 100644--- a/apps/desktop/scripts/build-webapp.mjs+++ b/apps/desktop/scripts/build-webapp.mjs@@ -37,7 +37,9 @@ export function mirrorWebappInputs(source, workspace) {}}-export async function buildSourceWebapp({+/** Mirror the inputs into the private workspace and install its dependencies, without compiling.+ * On its own it lets an image cache the install in a layer that only the manifests key. */+export function prepareWebappWorkspace({source = repoRoot, workspace, install = true, prepare = prepareNodeDependencies,} = {}) {source = resolve(source)@@ -50,14 +52,27 @@ export async function buildSourceWebapp({// The browser bundle never runs Electron, so its binary is not downloaded.electron: false,})+ return { source, workspace }+}++export async function buildSourceWebapp(options = {}) {+ const { source, workspace } = prepareWebappWorkspace(options)return buildWebapp({ source, workspace, out: join(source, 'apps/desktop/dist-webapp') })}if (isMain(import.meta.url)) {try {- const { values } = parseArgs({ options: { 'no-install': { type: 'boolean', default: false } } })- const result = await buildSourceWebapp({ install: !values['no-install'] })- console.log(`built ${result.index}`)+ const { values } = parseArgs({ options: {+ 'no-install': { type: 'boolean', default: false },+ 'deps-only': { type: 'boolean', default: false },+ } })+ if (values['deps-only']) {+ const { workspace } = prepareWebappWorkspace({ install: !values['no-install'] })+ console.log(`prepared ${workspace}`)+ } else {+ const result = await buildSourceWebapp({ install: !values['no-install'] })+ console.log(`built ${result.index}`)+ }} catch (error) {console.error(error)process.exitCode = 1