fix: dockerize backend reliably and optimization - #11
Merged
Merged
Conversation
- Pin @nestjs/swagger to 11.2.6 to fix ERR_PACKAGE_PATH_NOT_EXPORTED crash on startup (nestjs-zod incompatibility with 11.4.x) - Pin npm to 11.5.2 in Dockerfile and add BuildKit cache mounts for npm and tsc so rebuilds are near-instant - Prune dev deps in the builder stage and copy node_modules into the runtime stage instead of a second npm ci - Add healthcheck, init, and log rotation limits for the app service - Add seed:prod script that runs the compiled seeders (plain seed requires ts-node which is pruned from the production image) - Make the demo-user seed idempotent and log how many users were created (skips existing users by email) - Log a hint when ENABLE_DEMO_USERS_SEED is not enabled - Remove the stale 'Admin' role from the role seed - Regenerate package-lock.json (npm 11, lockfileVersion 3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
The backend couldn't run reliably in Docker: it crashed on startup,
demo users couldn't be seeded, and login from the frontend failed.
This PR fixes all three and slims down the build.
Fixes
@nestjs/swaggerto11.2.6(
11.4.xbreaksnestjs-zod→ERR_PACKAGE_PATH_NOT_EXPORTED).seed:prodscript that runs thecompiled seeders from
dist/(plainseedneeds ts-node, which ispruned from the production image). Seed is now idempotent + logs the
created count; added a hint when
ENABLE_DEMO_USERS_SEEDis off.Adminrole from the role seed.package-lock.jsonwith npm 11 (lockfileVersion 3).Optimization (build time ~9 min → ~3s)
11.5.2(matches lockfile).npm ciin the builder stage + BuildKit cache mounts for thenpm cache and the TypeScript incremental cache → near-instant rebuilds.
npm prune --omit=devin the builder; prunednode_modulesis copiedinto the runtime stage (no second full install).
appservice: addedhealthcheck,init: true, and log-rotationlimits.
How to test