Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support specifying path to .env.keys file #209

Open
motdotla opened this issue May 15, 2024 · 5 comments
Open

support specifying path to .env.keys file #209

motdotla opened this issue May 15, 2024 · 5 comments

Comments

@motdotla
Copy link
Contributor

this would unlock the ability to store the .env.keys file as a secret file - similar to what Render and others support:

render-vars

@insanity54
Copy link

insanity54 commented Jun 25, 2024

I'm going to +1 this, with some context.

I have made the mistake of adding, .env* to .gitignore, but forgetting to add .env* to .dockerignore, resulting in plaintext .env in a docker build artifact.

As long as .env.keys is present in my git repo, I think it's vulnerable to being leaked this way, or another way I haven't thought of yet. I would prefer it be out-of-band, safe in a place like ~/.config/dotenvx/

@motdotla
Copy link
Contributor Author

use dotenvx ext prebuild to make sure that never happens again in Docker.

RUN curl -fsS https://dotenvx.sh | sh

...

RUN dotenvx ext prebuild
CMD ["dotenvx", "run", "--", "node", "index.js"]

use dotenvx ext precommit --install to make sure it never happens in git.

$ dotenvx ext precommit --install
[dotenvx][precommit] dotenvx precommit installed [.git/hooks/pre-commit]

source

@motdotla
Copy link
Contributor Author

I would prefer it be out-of-band, safe in a place like ~/.config/dotenvx/

this is a good idea and something we'll consider.

ease of use and per project is still very important so I don't think it will be the default, but it will be an option that it will be easy to switch to as your default.

@RIP21
Copy link

RIP21 commented Aug 11, 2024

Another use case I would prefer is for monorepos to be able to have global .env.keys at the root of the repository. Having to copy-paste keys to multiple apps on onboarding is annoying.

So going up, up, up, up like, let's say, prettier and Node does when resolving modules to the root, is another good option. As doing --keys ../../.env.keys while OK and better than the workaround (like script that copies root one to apps below), is a tiny bit annoying/verbose :)

@SongRongLee
Copy link

SongRongLee commented Sep 11, 2024

I believe this feature would be highly beneficial, allowing users to decide how to manage .env.keys files within a monorepo or any type of project. In my use case, I prefer a project structure like this:

.
├── .env.keys
└── apps
    ├── app1
    │   └── .env.encrypted
    └── app2
        └── .env.encrypted

With this setup, I can define scripts in my package.json while specifying the key file (maybe using a -k option), for example:

...
"scripts": {
  "app1:encrypt": "dotenvx encrypt -f ./apps/app1/.env.encrypted -k ./env.keys",
  "app1:serve": "dotenvx run -f ./apps/app1/.env.encrypted -k ./env.keys -- serve-app1",
  "app2:encrypt": "dotenvx encrypt -f ./apps/app1/.env.encrypted -k ./env.keys",
  "app2:serve": "dotenvx run -f ./apps/app2/.env.encrypted -k ./env.keys -- serve-app2",
},
...

This approach avoids dealing with key concatenation for identical .env.xxx filenames (as discussed in #242). Additionally, if someone prefers to have separate .env.keys files for each app, they can do so by specifying the corresponding .env and .env.keys files easily. With such flexibility, we don't need to come up with new mechanism for different monorepo design. I hope this feedback helps improve the tool, and thank you for your hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants