How can I read in environment variables from a python env file for a script that is typically run in a Docker container?
In the Docker setup, the docker-compose.yml
specifies an env_file
with entries like:
DB_ADDR=rethinkdb
DB_PORT=28015
DB_NAME=ipercron
To run this locally, I want to convert these lines into:
os.environ['DB_ADDR'] = 'rethinkdb'
os.environ['DB_PORT'] = '28015'
os.environ['DB_NAME'] = 'ipercron'
Rather than writing a custom parser, are there any existing Python modules or tools to read environment variables from a python env file?