You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+23-1
Original file line number
Diff line number
Diff line change
@@ -501,7 +501,7 @@ password than your development database.
501
501
502
502
### Should I have multiple `.env` files?
503
503
504
-
No. We **strongly**recommend against having a "main" `.env` file and an "environment" `.env`file like`.env.test`. Your config should vary between deploys, and you should not be sharing values between environments.
504
+
We recommend creating on `.env` file per environment. Use `.env`for local/development,`.env.production` for production and so on. This still follows the twelve factor principles as each is attributed individually to its own environment. Avoid custom set ups that work in inheritance somehow (`.env.production` inherits values form `.env` for example). It is better to duplicate values if necessary across each `.env.environment` file.
505
505
506
506
> In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime.
507
507
>
@@ -660,6 +660,28 @@ Use [dotenv-vault](https://github.com/dotenv-org/dotenv-vault)
660
660
661
661
A `.env.vault` file is an encrypted version of your development (and ci, staging, production, etc) environment variables. It is paired with a `DOTENV_KEY` to deploy your secrets more securely than scattering them across multiple platforms and tools. Use [dotenv-vault](https://github.com/dotenv-org/dotenv-vault) to manage and generate them.
662
662
663
+
### What if I accidentally commit my `.env` file to code?
664
+
665
+
Remove it, [remove git history](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository) and then install the [git pre-commit hook](https://github.com/dotenvx/dotenvx#pre-commit) to prevent this from ever happening again.
666
+
667
+
```
668
+
brew install dotenvx/brew/dotenvx
669
+
dotenvx precommit --install
670
+
```
671
+
672
+
### How can I prevent committing my `.env` file to a Docker build?
673
+
674
+
Use the [docker prebuild hook](https://dotenvx.com/docs/features/prebuild).
0 commit comments