Docker image size with TanStack Start , pnpm
Hey folks 👋 I’m using TanStack Start with pnpm and Docker, and I’m noticing that my production Docker image is quite large 710 MB. Has anyone else experienced this? Is that size expected for a typical TanStack Start app, or might I be doing something wrong?
9 Replies
harsh-harlequinOP•2mo ago
My
Not sure if all of these need to be pulled in as dependencies of Start 🤔
package.json
dependencies
In my Docker build I install only (production) dependencies using:RUN pnpm install --frozen-lockfile --prod --ignore-scripts
I did some digging on the image size, seems a lot comes from transitive deps via @tanstack/react-start
, like @netlify/zip-it-and-ship-it
, precinct
, detective-typescript
, typescript
, prettier
, etc.Not sure if all of these need to be pulled in as dependencies of Start 🤔
correct-apricot•2mo ago
What are you putting in your docker container? Build makes everything, including a apckage.json and a node_modules folder in the output folder

harsh-harlequinOP•2mo ago
@Roderik | SettleMint Ah, that makes sense, thanks!
Switched to just copying the
.output
folder into the final image and dropped the extra installs. Now with node:24.3.0-alpine
the image is down to 159 MB. Appreciate the tip! 🙌harsh-harlequinOP•2mo ago
correct-apricot•2mo ago
use target: "bun", in the vite config and use the bun slim image for even less size and more speed
harsh-harlequinOP•2mo ago
That’s crazy, tried it image size is around 100MB 🤯
Not sure if I’ll switch yet, how are you finding it in production? Any caveats or cons to be aware of?
Not sure if I’ll switch yet, how are you finding it in production? Any caveats or cons to be aware of?
generous-apricot•2mo ago
Can you share the
Dockerfile
?harsh-harlequinOP•2mo ago
sorry don't have it anymore, just gave it a test run with bun, but for now sticking with node
correct-apricot•2mo ago
but i compile on the CI