Skip to content

fix: remove pnpm prune from Dockerfile (runtime deps in devDeps) - #11

Closed
stubbi wants to merge 4 commits into
mainfrom
fix/docker-no-prune
Closed

fix: remove pnpm prune from Dockerfile (runtime deps in devDeps)#11
stubbi wants to merge 4 commits into
mainfrom
fix/docker-no-prune

Conversation

@stubbi

@stubbi stubbi commented Mar 21, 2026

Copy link
Copy Markdown

Production is in CrashLoopBackOff — drizzle-orm pruned but needed at runtime.

stubbi and others added 4 commits March 21, 2026 22:23
Switch all workspace package exports from src/*.ts to dist/*.js so
the server runs on precompiled JavaScript without needing tsx as a
runtime transpiler.

Changes:
- All package.json exports fields now point to dist/ (previously
  pointed to src/ for development convenience, with publishConfig
  overriding for npm publish)
- Dockerfile CMD changed from node --import tsx/loader to node directly
- Dockerfile now prunes devDependencies (tsx no longer needed at runtime)
- Selective dist-only COPY in production stage works correctly now

Benefits:
- Faster startup (no runtime transpilation)
- Smaller image (no tsx, no TypeScript source in production)
- No devDependencies shipped
- More secure (no source code in production image)
- Reproducible (compiled output is deterministic)

Verified: server starts and runs correctly with node server/dist/index.js
without tsx loader.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TypeScript resolves types via the "types" condition (pointing to
src/*.ts for zero-build typechecking), while Node resolves runtime
imports via the "import" condition (pointing to dist/*.js).

This lets pnpm -r typecheck work without building first, while
the runtime still uses precompiled output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use Node's --conditions flag to switch between source and compiled
output:

- "default" → ./src/*.ts (dev, tests, typecheck — no build needed)
- "production" → ./dist/*.js (Docker, deployed environments)

Dockerfile CMD uses --conditions=production so Node resolves
workspace imports to precompiled dist/ output. Dev tools (vitest,
tsx, tsc) use the default condition and resolve to source.

Verified: typecheck passes, 569 tests pass, server starts with
--conditions=production without tsx.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upstream lists runtime deps like drizzle-orm in devDependencies.
Pruning removes them, causing ERR_MODULE_NOT_FOUND at runtime.
Image size is controlled by the selective COPY in the production
stage instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@stubbi stubbi closed this Mar 21, 2026
@stubbi
stubbi deleted the fix/docker-no-prune branch March 21, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant