From f7d57e95566dc34ce4272cae5326cd9bd89ee777 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 13 Sep 2026 01:16:23 +0200 Subject: [PATCH] The catalogue brings its own postgres driver The runtime base carries what every module needs, and a database driver is not that. Installed into an empty directory because the module's package.json also names the sdk, which lives in the base rather than on a registry. --- modules/mesh-catalog/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/mesh-catalog/Dockerfile b/modules/mesh-catalog/Dockerfile index ffa7d71..f0104d2 100644 --- a/modules/mesh-catalog/Dockerfile +++ b/modules/mesh-catalog/Dockerfile @@ -20,8 +20,22 @@ COPY . . RUN node /app/node_modules/typescript/bin/tsc pg.d.ts store.ts index.ts tools/index.ts \ --module NodeNext --moduleResolution NodeNext --target ES2022 --outDir dist +# **A module may need something the base image does not carry.** The base holds what every module +# needs — the sdk, the broker client — and a postgres driver is not that: the one other module that +# reaches a database shells out to psql instead. So the catalogue brings its own. +# +# Installed into an empty directory rather than into the module's, because the module's package.json +# also names `@novox/mesh-sdk`, which is not on any registry — it is in the base image. Asking npm to +# resolve this module's dependencies would therefore fail on the one it already has. +RUN mkdir -p /deps && cd /deps && \ + npm install --omit=dev --no-audit --no-fund --no-package-lock pg@8 + FROM ${RUNTIME_BASE} COPY --from=build /app/modules/mesh-catalog/dist /app/modules/mesh-catalog/dist +# Beside the compiled code, so `pg` resolves from it while `@novox/mesh-sdk` keeps walking up to the +# base image's own node_modules — the module gets its extra dependency without shadowing the sdk it +# was compiled against. +COPY --from=build /deps/node_modules /app/modules/mesh-catalog/node_modules # What a tool host should load: the catalogue's tools. Its consumer of `module.builder.built` is the # other entrypoint, and is what this module's own container runs — named in the declaration's `args` # rather than here, because which one runs is the declaration's business.