Next.js Discord

Discord Forum

Custom environment at runtime for nextjs docker image

Unanswered
devv posted this in #help-forum
Open in Discord
I have an app which would have a different environment for each deployment.

So it makes sense to build its docker images such that I only build a version of this app and pass environment variables while running the container instead of building the image with the environment.

But in the documentation it says that environment variables are replaced at build time. Is there any way I can do this?

(I am using nextjs app router)

17 Replies

Chinese Alligator
so what are u doing like what is the error u have ?
i m not that much expert in next js or tech but still i knew somehow can help
i knew what it feels when stuck on error
There is no error as such I'm just unable to do it. What I wanna do is build a version of my app and pass environment variables whenever I pull and run its container so that environment can be decided at deployment time
Chinese Alligator
okay like locally production or devlepoment in that sense ?
Nope, I mean like for one person the app would have some environment and for some other person the environment would be different
Chinese Alligator
okay get it
but never had touched docker so
not a singe pices of idea i have in docker related
so how much u knew in next js ?
I started using it in July
Chinese Alligator
okay
have u heard of error 504 GATEWAY_TIMEOUT ?
Yea
Chinese Alligator
so u are software enginner or else ?
i m facing an issue realted to that if u have time could u help on that
I checked out your post I think ur function takes too much time and that's why u get a timeout error