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_modulesand running next start$ time docker build . --no-cache
17.98s user 38.88s system 35% cpu 2:39.50 totalAfter: 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 totalClearly, 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_modulesto avoid missing deps?Message link in discussions: https://discord.com/channels/752553802359505017/752647196419031042/1409836386064011335
4 Replies
standalone mode takes care of everything
you just need to make sure you copy the assets and it is good
Chub mackerelOP
So in prod you just rely on standalone and copy the assets—anything else I should watch out for?
that should be all