DEV Community

Ibrahim Cesar
Ibrahim Cesar

Posted on • Updated on

Where do you store your .env files?

Given that .env files are not supposed to be committed, where do you usually store your .env files in order to share with other people in your team or between groups?

Top comments (8)

sonnk profile image
Nguyen Kim Son

This depends on your configuration management tools (Chef, Ansible, Puppet, etc), basically how you deploy your software. In small projects I usually use Ansible script that:

  1. copies the configuration file onto a server
  2. runs the docker image of the program

In this case the configuration file is stored along with the Ansible script. This file can be encrypted using ansible-vault. This setup is not ideal but works quite well for small projects.

tiguchi profile image
Thomas Werner

I store .env files (and similar) in my continuous integration system (e.g. Jenkins) and let it automatically add the file when the project is built. If there is anything to be shared (i.e. default settings that are not confidential secrets) then I put it into a template file which I add to the project's repository (e.g. .env.template).

ozzyogkush profile image
Derek Rosenzweig • Edited

If you don't use configuration management tools (Chef, Puppet, etc), you can store them in Gists, Confluence, or similar documentation products. Also you can provide a default eg .env.default that can be used as a prototype with basic values (local env URL, local service configs, etc). At the very least, the default/template can list out the env variables that the app supports in any given commit.

endorama profile image
Edoardo Tenani • Edited

If you do dotenv sensibly, there should be no need to be shared in the team.

It's true that 12factor app ask you to out configuration in the environment, but this does not mean to add them in a .env file.

Put only personal configuration there, like your token for a service, and put every other configuration in committed configuration files.

If you go down this path you will find that .env are very personal and thus there should be no need to share them.

If for some special reason you need to share them, encrypt them and share any way you like. gpg or a service like may come handy.

The only other path, but beware that may have some unintended consequences, is to commit a .env.default sort of file that each Dev has to copy and fill appropriately.

May I ask you what configurations are in your .env file?

kay_2695px profile image

Have you considered secure-env? Full disclosure, this is an NPM I made out of necessity. how-secure-is-your-environment-fil...?

imprimph profile image

Hey kunal, i am using the secure-env package for one of my personal projects, but i am using typescript, is there types files for this package?

syuraj profile image
Suraj Shrestha

I tend to put in Google Drive or copy from prod/qa environment directly

bradtaniguchi profile image

We used to just pass them around in a USB. We eventually updated our projects to use to use Google KMS + Google storage, this way the secrets are encrypted and can be loaded anywhere.