.env not found in docker
Hello,
project structure:
root_directory | --recommencer |-- src |-- services init.py extract.py (which is calling config = dotenv_values('../.env') -> it works locally) init.py app.py .env (is in the root_directory)
While building my docker image and start my container (I've the same structure in my docker image/container as locally), extract.py can't find .env anymore, I have to call it like this config = dotenv_values('.env'). This make local testing difficult as I've to change how I call config = dotenv_values() while peforming my local test and change it to build my image.
Any idea how I can solve this without changing my project structure?
I recently started seeing the same problem. I've given up on debugging it and decided to manually fix it by doing something like:
config = dotenv_values('.env')
if os.environ.get("IMPORTANT_ENV") == None:
os.environ["IMPORTANT_ENV"] = config.get("IMPORTANT_ENV")
I did the same,
flask_debug = os.environ.get('FLASK_DEBUG')
config = any
if flask_debug is not None:
config = dotenv_values('.env')
else:
config = dotenv_values('../.env') # for local testing