Fix container not starting if data dir did not exist

This commit is contained in:
Esa Kataja
2025-05-13 21:10:32 +03:00
parent 4a480a312e
commit 9ecdc1b040
2 changed files with 5 additions and 0 deletions
+1
View File
@@ -12,4 +12,5 @@ FROM base
COPY --from=builder /app /app
ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app
RUN mkdir -p /app/data
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
+4
View File
@@ -79,8 +79,12 @@ def seed_db() -> None:
def init_db():
logger.info("Initializing database...")
if Path(DB_PATH).exists():
return
logger.info("Database does not exist, creating...")
if not Path(DB_PATH).parent.exists():
Path(DB_PATH).parent.mkdir(parents=True, exist_ok=True)
with open(SQL_PATH, "r") as f:
sql = f.read()
with get_connection() as conn: