You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tl;dr: I'd like to update SSG files on build step without rebuilding static JS chunks and CSS, and I can't find an easy way to achieve this.
Here's a problem I encountered:
I currently run next build in production (in k8s initContainer), but it's consuming a lot of CPU and memory and sometimes brings my production cluster down or slows it down significantly.
Also it means that I have to rebuild all JS chunks every time the container restarts.
I could limit next build CPU consumption but I don't like this solution since it'd slow the deployment process.
I also don't want to run next build on docker build step in CI because it'd mean users might see old SSG pages if container ever restarts (due to the way stale-while-revalidate logic in getStaticProps works).
I already use CDN (via Next.js assetPrefix feature), so I don't really need .next/static dir in my docker image. I just need to build it once when my code changes, but I also want to (re)build SSG pages each time I spin up a new container.
I suspect (but haven't checked) that building .next/static is the most heavy part of the build process (calling webpack, etc.), while building .next/server is a relatively lightweight process, at least in my case.
So the optimal solution for me would be to build .next/static in my CI pipeline on a separate build server (and then upload it to S3/Cloudfront/whatever), while building SSG pages in production when container actually starts, so that SSG pages are always fresh at the start.
Is it possible to achieve this with Next.js? Am I missing some other solution? How people usually solve this problem?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
tl;dr: I'd like to update SSG files on build step without rebuilding static JS chunks and CSS, and I can't find an easy way to achieve this.
Here's a problem I encountered:
next build
in production (in k8s initContainer), but it's consuming a lot of CPU and memory and sometimes brings my production cluster down or slows it down significantly.next build
CPU consumption but I don't like this solution since it'd slow the deployment process.next build
on docker build step in CI because it'd mean users might see old SSG pages if container ever restarts (due to the way stale-while-revalidate logic in getStaticProps works).I already use CDN (via Next.js assetPrefix feature), so I don't really need
.next/static
dir in my docker image. I just need to build it once when my code changes, but I also want to (re)build SSG pages each time I spin up a new container.I suspect (but haven't checked) that building
.next/static
is the most heavy part of the build process (calling webpack, etc.), while building.next/server
is a relatively lightweight process, at least in my case.So the optimal solution for me would be to build
.next/static
in my CI pipeline on a separate build server (and then upload it to S3/Cloudfront/whatever), while building SSG pages in production when container actually starts, so that SSG pages are always fresh at the start.Is it possible to achieve this with Next.js? Am I missing some other solution? How people usually solve this problem?
Beta Was this translation helpful? Give feedback.
All reactions