I’m running a FastAPI app in a Docker container. For the app to work it needs access to its secrets, which are in a folder inside the app (for local development only), however, it can’t find the secrets directory.
My file structure inside the container’s working directory is the following:
project/
├── app/
│ └── secrets/
│ └── LOCAL_DEV/
├── environments/
│ └── LOCAL_DEV/
└── main.py
The working directory is set as “project”, and adding the following debug statement:
BASE_DIR = Path(__file__).resolve().parent
logger.debug(f"Current base directory: {BASE_DIR}")
Confirms that the current directory is “/project”, however, when it’s time to extract the secrets, the program fails with:
directory "app/secrets/LOCAL_DEV" does not exist
Everything runs fine when running it outside of the container, what am I missing here?