Next.js Discord

Discord Forum

Docker + NextJS - Environment Variables/Secrets

Unanswered
Ghost ant posted this in #help-forum
Open in Discord
Ghost antOP
How do you build in a CI without exposing the secrets in the docker?

I have to build a docker image, but I just cannot find a way of building the docker image without exposing the environment secrets in the container.

I will have them available later in K8S at runtime, but during buildtime in the pipeline seems almost impossible since the without .env it does fail fetching the routes (which can't be disabled)

2 Replies

Ghost antOP
i think is more of handling envs at build vs run time, this would force me to prefix each route in force-dynamic which is not what I am looking for, the use case is the following:

- i have a nextjs project that I build with Docker and use standalone output in a CI
- then would like be able to swap variables as needed (one image - different environments) without exposing those in the Docker image
- then on runtime use the env exported in the k8s cluster