I'm trying to dockerize my project, and I've come up with the following file structure:
project/
├── app1/
│ ├── main.py
│ ├── Dockerfile
│ └── venv/
├── app2/
│ ├── main.py
│ ├── Dockerfile
│ └── venv/
├── .env
└── docker-compose.yml
In each main.py
, I would like to use pydantic's BaseSettings
to read env vars from .env
file.
from pydantic import BaseSettings
class Config(BaseSettings):
VAR: str
class Config:
env_file = "???"
config = Config()
The question is: how do I use my single .env
file each main.py
file? Or have I already used some antipatterns and this isn't possible with the current file structure?
PS. I understand that it has nothing to do with docker, it's there for context.