chore(backend): move build tooling out of runtime dependencies - #2793
Merged
Conversation
The Nest CLI, schematics, testing module, rimraf and the Prisma CLI are build-time tools, but were listed as runtime dependencies. That put their whole subtree in the production graph, so the dependencies stage of the Dockerfile copied the build toolchain into the distroless runtime image, and Trivy counted its transitive advisories as production findings. The build stage runs a full npm ci before nest build, so the build is unaffected. Clears three of the four HIGH findings currently open.
This was referenced Jul 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces the backend production dependency footprint by moving NestJS build/test tooling and other CLIs from dependencies to devDependencies, aligning with the Dockerfile’s npm ci --omit=dev runtime install behavior.
Changes:
- Moved
@nestjs/cli,@nestjs/schematics, and@nestjs/testingtodevDependencies. - Moved
prisma(CLI) andrimraftodevDependencies. - Updated
backend/package-lock.jsonaccordingly to reflect the dev/prod classification changes.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/package.json | Reclassifies build/test tooling and CLIs as dev-only dependencies. |
| backend/package-lock.json | Lockfile updates reflecting the dependency/devDependency move. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 27, 2026
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.
Problem
backend/package.jsonlisted@nestjs/cli,@nestjs/schematics,@nestjs/testing,rimraf, and theprismaCLI as runtimedependencies. Two consequences:dependenciesstage ofbackend/Dockerfilerunsnpm ci --omit=devand copies the result into the distroless runtime image, so the Nest build toolchain, webpack, and fork-ts-checker were shipping to production.brace-expansionalerts came from there.Change
Those five packages move to
devDependencies. Nothing else. The build stage runsnpm run deploy, which is a fullnpm cifollowed bynest build, so the build has everything it needs.Note that this does not remove the Prisma CLI from the production tree:
@prisma/clientdeclares an optional peer dependency onprisma, which npm installs regardless of where it is listed. Advisories reaching the report through that path are handled separately.Results
node_modules/@nestjs/cliis absent from that tree afterwards.brace-expansionalerts cleared.Verification
npm run deploy, the exact command the Dockerfile build stage runs: prisma generate and nest build both succeed, 0 TypeScript issues.npm test: 8 files, 32 tests passing.npm ci --omit=devfollowed bynode dist/mainagainst an unreachable database: "Nest application successfully started", confirming nothing the runtime needs was moved out.Thanks for the PR!
Deployments, as required, will be available below:
Please create PRs in draft mode. Mark as ready to enable:
After merge, new images are deployed in: