When building huge sites of up to 30k static blog posts for example, it can be really resource intensive, and not possible on smaller servers with limited CPU.
For example for my site, I've got 8gb of RAM, and it still struggles to build a blog of 6000 pages. I tried next.js's experimental config, limiting to 3 cpus, and also batching up the static build with timeouts. However, it still sometimes fails:

It often failed because the next build process uses a lot of RAM, and the next build process is pinging my backend to build the content. Because both next app and my backend are on the same VPS, there's 2 large processes.
Therefore, if I can build the Next app locally, it pretty much halves the resources required to build my site. To do this, I came across this Reddit thread with various links on building locally, and deploying the output. It turns out it's possible with 'next.js output':
This post shows how I set mine up, including some steps if you're deploying on Coolify like me. Otherwise Docker is probably similar.

Buy me a coffee



