So I feel it's very clear how to use dotenv locally, but what's the alternatives when deploying?
Should we just skip using dotenv, or should we use it with a limited set of env values that are commitable?
How does dotenv solve our production/test-server env variable setup?
Any advices? I couldn't find any docs on it.
should we use it with a limited set of env values that are commitable?
I strongly suggest not committing any environment variables.
How does dotenv solve our production/test-server env variable setup?
It _really_ depends on your setup and because there are so many ways to do things, it's hard to document. There are two key questions to answer:
.env file)If you're deploying to a server or VM like AWS EC2 or Digital Ocean, then you can put a .env file on that server where your app runs and it's exactly like running things locally.
If you use something like Heroku Dynos or AWS Elastic Beanstalk, environment variables are provided for you and should match what's in your local .env file. dotenv fails silently when the .env file is missing and everything should work as expected. (If you don't like the log line when the file is missing, use the silent configuration option.)
If you're deploying using a container system like Docker, you can use their configuration arguments or Compose to set environment variables.
Hope this helps!
If you use something like Heroku Dynos or AWS Elastic Beanstalk, environment variables are provided for you and should match what's in your local .env file. dotenv fails silently when the .env file is missing and everything should work as expected. (If you don't like the log line when the file is missing, use the silent configuration option.)
This was the answer I needed, so thank you!
save my day 馃憤
Most helpful comment
I strongly suggest not committing any environment variables.
It _really_ depends on your setup and because there are so many ways to do things, it's hard to document. There are two key questions to answer:
.envfile)If you're deploying to a server or VM like AWS EC2 or Digital Ocean, then you can put a
.envfile on that server where your app runs and it's exactly like running things locally.If you use something like Heroku Dynos or AWS Elastic Beanstalk, environment variables are provided for you and should match what's in your local
.envfile. dotenv fails silently when the.envfile is missing and everything should work as expected. (If you don't like the log line when the file is missing, use thesilentconfiguration option.)If you're deploying using a container system like Docker, you can use their configuration arguments or Compose to set environment variables.
Hope this helps!