Added warning if in docker and data dir isn't mounted

Had to remove the VOLUME definition in the dockerfile for this, otherwise the data dir would always be mounted by an anonymous volume if the user didn't mount it correctly, so the python script wouldn't be able to detect it.
This commit is contained in:
Donkie
2023-11-07 21:45:52 +01:00
parent d55dde5bfe
commit fef41a5628
3 changed files with 29 additions and 1 deletions

View File

@@ -95,6 +95,22 @@ async def startup() -> None:
logger.info("Startup complete.")
if env.is_docker() and not env.is_data_dir_mounted():
logger.warning("!!!! WARNING !!!!")
logger.warning("!!!! WARNING !!!!")
logger.warning("The data directory is not mounted.")
logger.warning(
'Spoolman stores its database in the container directory "%s". '
"If this directory isn't mounted to the host OS, the database will be lost when the container is stopped.",
env.get_data_dir(),
)
logger.warning(
"Please carefully read the docker part of the README.md file, "
"and ensure your docker-compose file matches the example.",
)
logger.warning("!!!! WARNING !!!!")
logger.warning("!!!! WARNING !!!!")
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)