Nextjs and Kubernetes - Separating build and runtime

Viewed 438

I have been looking for a way to reduce cpu and memory allocation in my kubernetes pod for my nextjs app. Due to constraints, I need to run next build on first container launch, which requires significant memory and cpu, but once it's built, it doesn't need much at all.

I've tried init containers, but according to the docs, the pod picks the highest values in the cpu and memory specification, and sets that for the entire pod. I'm using Argocd.

I'm wondering if anyone has any recommendation of things to look into, or, if they've faced this problem before, what steps they took to solve it.

Ideally I would like to segregate the allocation between the build and runtime phase. I thought maybe spinning up a container, building the app, then passing over the assets to the runtime container?

0 Answers
Related