Skip to content

Commit a44cb3d

Browse files
committedJan 23, 2024·
update README
1 parent e8c23e7 commit a44cb3d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed
 

‎README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ password than your development database.
501501

502502
### Should I have multiple `.env` files?
503503

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.
505505

506506
> 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.
507507
>
@@ -660,6 +660,28 @@ Use [dotenv-vault](https://github.com/dotenv-org/dotenv-vault)
660660

661661
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.
662662

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).
675+
676+
```bash
677+
# Dockerfile
678+
...
679+
RUN curl -fsS https://dotenvx.sh/ | sh
680+
...
681+
RUN dotenvx prebuild
682+
CMD ["dotenvx", "run", "--", "node", "index.js"]
683+
```
684+
663685
## Contributing Guide
664686

665687
See [CONTRIBUTING.md](CONTRIBUTING.md)

0 commit comments

Comments
 (0)
Please sign in to comment.