ENV with next.js and docker
Answered
White-tailed Tropicbird posted this in #help-forum
White-tailed TropicbirdOP
I have a workflow in GitHub and I have an API key I use in one of the routes I declared in my application, when I deploy I set the environment variables in my docker application but the next.js server doesn't seem to grab system env variables, what would be a good option for not exposing my .env file in my GitHub repository and being able to set environment variables within my docker container so the next.js server grabs them?
Answered by White-tailed Tropicbird
Yeah, that's not inside my possibilities, I found why my problem is, and it's because static generation of env variables, since I don't want any env variables to be pushed to the docker registry, I need to opt into dynamically generated variables
6 Replies
@White-tailed Tropicbird I have a workflow in GitHub and I have an API key I use in one of the routes I declared in my application, when I deploy I set the environment variables in my docker application but the next.js server doesn't seem to grab system env variables, what would be a good option for not exposing my .env file in my GitHub repository and being able to set environment variables within my docker container so the next.js server grabs them?
Munchkin
Hi, The way i did this creating a .env file in your folder and just writing over the variables like: ${{secrets.ENV VARIABLE}}
or part of this to be exact
@Munchkin Hi, The way i did this creating a .env file in your folder and just writing over the variables like: ${{secrets.ENV VARIABLE}}
White-tailed TropicbirdOP
Yea so you mean creating a .env file and copying it inside the container?
Munchkin
yeah
White-tailed TropicbirdOP
Yeah, that's not inside my possibilities, I found why my problem is, and it's because static generation of env variables, since I don't want any env variables to be pushed to the docker registry, I need to opt into dynamically generated variables
Answer