dump-env
takes an .env.template
file and some optional environmental variables to create a new .env
file from these two sources.
Why do we need such a tool? Well, this tool is very helpful when your CI is building docker
(or other) images.
Previously we had some complex logic of encrypting and decrypting files, importing secret keys and so on.
Now we can just create secret variables for our CI, add some prefix to it, and use dump-env
to make our life easier.
This quick demo will demonstrate the main and the only purpose of dump-env
:
$ dump-env --template=.env.template --prefix='SECRET_ENV_' > .env
This command will:
- take
.env.template
- parse its keys and values
- read and all the variables from the environment starting with
SECRET_ENV_
- remove this prefix
- mix it all together, where environment variables could override ones with the same name from the template
- sort keys in alphabetic order
- dump all the keys and values into the
.env
file
$ pip install dump-env