From 782dc225bfa27b7e51ed74efff3daaa081874931 Mon Sep 17 00:00:00 2001 From: Johngreen Date: Tue, 10 Feb 2026 12:36:01 +0900 Subject: [PATCH] feat(ci): auto-run alembic migrations and seed on container start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add entrypoint.sh (migrate → seed → uvicorn) - Add python-dotenv to requirements.txt - Backend container uses entrypoint instead of direct uvicorn Co-Authored-By: Claude Opus 4 --- Containerfile.backend | 2 +- requirements.txt | 3 +++ scripts/entrypoint.sh | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/entrypoint.sh diff --git a/Containerfile.backend b/Containerfile.backend index 4265a10..1fbb3f5 100644 --- a/Containerfile.backend +++ b/Containerfile.backend @@ -20,4 +20,4 @@ ENV PYTHONUNBUFFERED=1 EXPOSE 8000 -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["sh", "scripts/entrypoint.sh"] diff --git a/requirements.txt b/requirements.txt index 82aea87..1c34720 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,9 @@ sqlalchemy[asyncio]==2.0.36 asyncpg==0.30.0 alembic==1.14.0 +# Env +python-dotenv==1.0.1 + # Auth PyJWT==2.9.0 bcrypt==4.2.0 diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100755 index 0000000..44fc5a0 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +echo "Running Alembic migrations..." +python -m alembic upgrade head + +echo "Running seed data..." +python scripts/seed.py + +echo "Starting uvicorn..." +exec uvicorn main:app --host 0.0.0.0 --port 8000