dotenv-vault icon indicating copy to clipboard operation
dotenv-vault copied to clipboard

Is it possible to manage multiple .env

Open rymbekov opened this issue 3 years ago • 6 comments

For example, use in one project for docker-compose containers .env-a, .env-b, .env-c, but taking into account production and stage environment

rymbekov avatar Nov 17 '22 09:11 rymbekov

Can you elaborate further? So you are use 3 different env files that are ALL for production environment? Or does each file represent an environment?

motdotla avatar Nov 17 '22 17:11 motdotla

This would useful for sharing secrets between environments. e.g. -e .env.development -e .env.shared

hbriese avatar Nov 20 '22 01:11 hbriese

@hbriese interesting. Why not just place all those secrets in development though? Why maintain a shared and require a developer to look in 2 places - more mental effort?

(dotenv-vault already auto-copies over your dev keys to your other environments)

motdotla avatar Nov 20 '22 05:11 motdotla

@motdotla very valid points, and that is exactly the approach we have taken. I have seen such a feature on similar tooling and was trying to guess at the case OP was making

hbriese avatar Nov 23 '22 12:11 hbriese

I see. Thanks @hbriese.

@rymbekov can you elaborate further? Why do you currently prefer to have multiple .envs for a docker compose container? Do you boot up the docker compose container in development and then separately boot it up in staging and/or prod on your servers?

motdotla avatar Nov 23 '22 15:11 motdotla

(dotenv-vault already auto-copies over your dev keys to your other environments)

Does it? Using dotenv-vault, the behavior I see documented and in practice is that any value not defined in an environment becomes an empty string. So if you define say a "production" environment, then do nothing else, then do npx dotenv-vault pull production you end up with a .env.production file filled with empty strings.

How can this behavior be changed and/or how can it be made to inherit values from the development environment, which would be the sensible behavior?

joshlytle avatar Mar 07 '23 04:03 joshlytle