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 <noreply@anthropic.com>
This commit is contained in:
parent
92b3afe9d6
commit
80a6c1e140
2 changed files with 8 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
FROM python:3.12-slim
|
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
|
WORKDIR /app
|
||||||
COPY pyproject.toml .
|
COPY pyproject.toml .
|
||||||
RUN pip install --no-cache-dir -e ".[mcp]"
|
RUN pip install --no-cache-dir -e ".[mcp]"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
until pg_isready -q -h postgres; do
|
||||||
|
echo "Waiting for postgres..."
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
alembic upgrade head
|
alembic upgrade head
|
||||||
exec uvicorn corvid.main:app --host 0.0.0.0 --port 8080
|
exec uvicorn corvid.main:app --host 0.0.0.0 --port 8080
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue