---
title: "Comment by Node Edge Ops on \"Multi-Stage Docker Builds for NestJS: What Nobody Tells You\" | Hashnode"
description: "A Nest multi-stage image stays reliable when the builder alone runs install plus nest build (and any prisma generate / native compile), then the runtime stage c"
url: "https://hashnode.com/posts/multi-stage-docker-builds-for-nestjs-what-nobody-tells-you/69e372c99020749e6a1bd912/comment/6aec2018e62b831a8fd3b8cf"
---

[Discussion](https://hashnode.com/posts/multi-stage-docker-builds-for-nestjs-what-nobody-tells-you/69e372c99020749e6a1bd912)

Comment [Multi-Stage Docker Builds for NestJS: What Nobody Tells You](https://hashnode.com/posts/multi-stage-docker-builds-for-nestjs-what-nobody-tells-you/69e372c99020749e6a1bd912)

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[Nov 5](https://hashnode.com/posts/multi-stage-docker-builds-for-nestjs-what-nobody-tells-you/69e372c99020749e6a1bd912/comment/6aec2018e62b831a8fd3b8cf)

A Nest multi-stage image stays reliable when the builder alone runs install plus nest build (and any prisma generate / native compile), then the runtime stage copies only dist, the pruned production node\_modules, and the lockfile-derived tree — never the compiler, never a leftover .npm cache. Match libc between stages (glibc vs musl) so bcrypt-style .node addons do not fail at ERR\_DLOPEN after a “green” build. Listen on a private interface or Compose network only, run as non-root, set NODE\_ENV=production, and fail the image build if a required native binding is missing for the runtime arch rather than discovering it on first boot behind a proxy.

After rebuild I exec into the runtime container and require the native module once, then hit a readiness route that boots Nest plus a trivial crypto or DB ping from an adjacent proxy container on the internal network, and finally the same path through published TLS. A short 502 with a healthy container almost always means wrong internal port, missing network membership, or the process still compiling on start — move generation into the builder and keep start as node dist/main. Log upstream status beside request time at the edge so a crash-looping Nest worker is not mistaken for TLS or vhost drift.
