I need to set an Environment variable when running pipenv shell; however, I do not want to throw the variable into the .env file since it's from a secret file and I do not want to upload that to github.
Is there a way I could automatically set Environment Variables on "pipenv shell" using python imports? This way I could use the configparser library to pull variables from the secret file.
The reason I want to do this is so I can pull that environment variable into the docker-compose.yml file when in the python environment since I can't use python imports. Here is my docker-compose.yml file to give an idea of what I'm trying to do.
version: "3.9"
services:
db:
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=selenium-db
- POSTGRES_USER=${DATABASE_USER}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
volumes:
- ./postgres-data:/var/lib/postgresql/data
As you can see I need a way of dynamically setting the DATABASE_USER and DATABASE_PASSWORD environment variables.