Next.js Discord

Discord Forum

Single Docker Image for Next.js: Runtime Env Var Strategy?

Unanswered
porto posted this in #help-forum
Open in Discord
I'm looking for a recommended way to deploy Next.js applications using a single Docker image across multiple environments. The core challenge is that both my server-side and client-side environment variables need to be defined and read at runtime for each specific environment.

Is there a standard or widely recommended solution within the Next.js ecosystem to achieve this? I've been exploring libraries like next-runtime-env, but I have some security concerns that I've detailed in this GitHub issue: https://github.com/expatfile/next-runtime-env/issues/187 I'd appreciate any insights or alternative approaches you might have for securely handling runtime environment variables in a single-image Docker deployment.

0 Replies