Commit 4d615d6
committed
fix(registry): use pnpm deploy for monorepo-aware Dockerfile
#100 switched the registry's `@nimblebrain/mpak-schemas` dep from
`^0.2.0` (published) to `workspace:*` so schemas changes are
immediately consumable without a publish-bump dance — matching the
convention every other package in the workspace already uses
(`cli`, `sdk-typescript`, `web`). The Dockerfile, however, was
written single-package and only copied `apps/registry/`, never any
workspace dep source. Build then errored across every file
importing schemas:
src/routes/auth.ts(3,53): error TS2307: Cannot find module
'@nimblebrain/mpak-schemas' or its corresponding type declarations.
... (15 more)
## The fix: `pnpm deploy`
`pnpm deploy --filter=<pkg> --prod <out>` is pnpm's purpose-built
solution for "containerize a workspace package": it walks the full
dependency closure (workspace + npm), builds a flattened deployable
directory, and resolves all `workspace:*` links by bundling each
workspace package's compiled `dist/` inline. Single COPY in the
runtime stage; future workspace deps require no Dockerfile change.
Builder stage:
- `COPY . .` brings the whole monorepo in (kept lean by .dockerignore).
- `pnpm install --frozen-lockfile` resolves all workspace links.
- `pnpm --filter ... exec prisma generate` writes the generated client
into the pnpm hoisted store.
- `pnpm --filter @nimblebrain/mpak-registry... build` builds the
registry AND every transitive workspace dep (`...` filter syntax).
- `pnpm deploy --filter=@nimblebrain/mpak-registry --prod /deploy`
flattens registry + prod deps + workspace closures into /deploy.
Production stage:
- One `COPY --from=builder /deploy ./` brings everything the runtime
needs — registry dist, schemas dist, every npm prod dep.
- The Prisma generated client is the one exception: its sibling
`.prisma/` folder lives in the pnpm hoisted store and isn't carried
by `pnpm deploy`. Two explicit COPY lines preserved from the prior
Dockerfile handle that special case.
`.dockerignore` (new) keeps the build context small — excludes every
package's `node_modules`, `dist`, `.astro`, `.turbo`, `.git`, `.env*`,
test outputs, editor state.
## Verified locally
- `docker build -f apps/registry/Dockerfile -t mpak-registry:test .` →
succeeds end-to-end (was failing on the original tsc step).
- `docker run mpak-registry:test` → boots: Prisma initializes, every
module loads, Fastify listens on :3200.
- `node -e "import('@nimblebrain/mpak-schemas').then(...)"` inside
the image → schemas resolves, `ServerDetailSchema` is an object.
## Why not the simpler `COPY packages/schemas/...` patch
Considered first, rejected because it's per-dep — every future
workspace dep added to the registry would need another COPY pair in
both stages. `pnpm deploy` is what pnpm's monorepo-Docker docs
recommend and scales to N workspace deps with no Dockerfile churn.1 parent 238a13e commit 4d615d6
2 files changed
Lines changed: 85 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | | - | |
9 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | | - | |
23 | | - | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | | - | |
26 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | | - | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 50 | + | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
| |||
0 commit comments