Does dotenv contradict the Twelve-Factor App?
12factor is not violated until somebody actually commits and pushes the .env
;)
The .env
file can also be stored outside the repo itself, since a library or app is still has to read the .env
file and push the variables into the environment. Depending on your implementation, this can be as simple as changing the path from ".env"
to "../.env"
.
Using .env
files can be a good compromise to allow developers to manage environments easily, but still be compatible with better environment practices during deployment. I might have 30-40 12factor-flavored apps running in a virtual machine, and having to manage each environment separately is daunting without a "shim" like .env
.