Docker Image Bloat - #692
Merged
Merged
Conversation
conservationtimothy
marked this pull request as draft
September 21, 2026 11:54
conservationtimothy
marked this pull request as ready for review
September 21, 2026 12:00
IamJeffG
requested review from
Atmosfearful
and removed request for
IamJeffG
September 21, 2026 14:12
Atmosfearful
approved these changes
Sep 21, 2026
Atmosfearful
left a comment
Contributor
There was a problem hiding this comment.
Nice cleanup, agree we don't need pnpm for prod images
Contributor
|
what's the new image size? |
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.
Goal
Reduce the size of the production Docker image. The image grew from about 600 MB to about 1 GB after the pnpm 11 upgrade. Closes #673 .
Screenshots
App starts up !
What I changed and why
The production image was installing pnpm and running
pnpm install --prod, but the running application does not use those production dependencies. Nitro builds a standalone Node server into.output, and the container starts it directly withnode .output/server/index.mjs.I removed the unnecessary production-stage pnpm install and now copy only the files required at runtime: the Nitro
.outputdirectory, the start script, and the SQL migration files used by the migration plugin.This also prevents pnpm’s registry metadata cache under
/root/.cache/pnpmfrom being included in the final image, reducing unnecessary image size. The build stage is unchanged.How I convinced myself this is right
I compared published images
20260831-1059(before pnpm 11),20260902-1066(pnpm 11), and20260918-1166(latest).docker historyshowed thepnpm install --prodlayer growing from 358 MB to 756 MB, while the application output remained about 14 MB. The pnpm 11 image also contained a new ~385 MB cache under/root/.cache/pnpm, along with unused/app/node_modulesand the global pnpm installation.I then built the changed Dockerfile locally. The resulting image was 261 MB uncompressed and 83 MB compressed. The container still exited when database environment variables were missing. With test database environment variables set, the server reached `Listening on http://[::]:8080.
This confirmed that the application can load and start from
.outputwithout/app/node_modules.What I'm not doing here
I do not change the build stage. I do not change the start script or the migration file path.
LLM use disclosure
None