docker-compose .env vs direnv .envrc
I use the following setup to have variables available during dev from .envrc
but using a docker-compose
file for deployment:
In ./secrets
define your variables as docker-compose needs them (without export):
foo=bar
secret_var=secret
...
In ./envrc
export them to your shell:
#!bash
set -a
. ./secrets
set +a
set -a
makes everything export by default, set +a
turns this off afterwards.
Here is an alternative solution based on the comment chain for this answer
direnv ships with a stdlib that can be used to support classical 'dotenv' settings
# myproject/.envrc - name of current file
# Usage:
# dotenv <optionalPathToDotEnvFile> or defaults to .env
dotenv
# myproject/.env
FOO=BAR
this is especially helpful when using container systems like docker that support the dotenv style