From 80a6c1e1402340bc856433b479dc99cc30260c62 Mon Sep 17 00:00:00 2001 From: Kevin Welvaert ATA IT Date: Wed, 27 May 2026 09:12:08 +0200 Subject: [PATCH] fix: wait for postgres before running migrations on startup App was crash-looping when the host restarted and Docker brought up the app container before postgres was ready. Added a pg_isready poll loop in entrypoint.sh and installed postgresql-client in the image. Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 2 ++ entrypoint.sh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index b98eb56..290a985 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM python:3.12-slim +RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client && rm -rf /var/lib/apt/lists/* + WORKDIR /app COPY pyproject.toml . RUN pip install --no-cache-dir -e ".[mcp]" diff --git a/entrypoint.sh b/entrypoint.sh index 2b9f254..1c0f93b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,10 @@ #!/bin/sh set -e + +until pg_isready -q -h postgres; do + echo "Waiting for postgres..." + sleep 2 +done + alembic upgrade head exec uvicorn corvid.main:app --host 0.0.0.0 --port 8080