Which Docker build approach is safer for Next.js in production?
Unanswered
Chub mackerel posted this in #help-forum
Chub mackerelOP
Hey folks 👋
At work we have a relatively big Next.js app and I noticed a huge difference in Docker build times depending on the approach:
Before: Copying the whole
After: Using Next.js output: "standalone" and only copying .next/standalone (plus public and package files)
Clearly, the standalone approach is much faster and results in a smaller image.
But I’m wondering: which method do you consider safer for production?
Do you trust standalone completely, or do you still prefer copying all of
At work we have a relatively big Next.js app and I noticed a huge difference in Docker build times depending on the approach:
Before: Copying the whole
node_modules
and running next start$ time docker build . --no-cache
17.98s user 38.88s system 35% cpu 2:39.50 total
After: Using Next.js output: "standalone" and only copying .next/standalone (plus public and package files)
$ time docker build . --no-cache
0.16s user 0.18s system 7% cpu 4.777 total
Clearly, the standalone approach is much faster and results in a smaller image.
But I’m wondering: which method do you consider safer for production?
Do you trust standalone completely, or do you still prefer copying all of
node_modules
to avoid missing deps?Message link in discussions: https://discord.com/channels/752553802359505017/752647196419031042/1409836386064011335