From 0b4f9f5c0e79d7bdd1eb3f76a0fb50a1634b51be Mon Sep 17 00:00:00 2001 From: jerick Date: Mon, 20 Apr 2026 15:25:02 -0400 Subject: [PATCH] fix: add setup service for db push/seed; update README The production runner image has no node_modules, so prisma CLI and tsx are unavailable. Add a Compose 'setup' profile service that uses the builder stage (which has all dev tools) to run db push and db seed. Co-Authored-By: Claude Sonnet 4.6 --- README.md | 20 ++++++++++++-------- docker-compose.yml | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3c18a4c..68b66fa 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,19 @@ Edit `.env`: - Change `POSTGRES_PASSWORD` to a strong password ```sh -# 2. Build and start the stack -docker compose up --build -d +# 2. Build the images +docker compose build -# 3. First-run only: apply the schema and create your user -docker compose exec app npx prisma db push -docker compose exec app npx prisma db seed +# 3. Start the database +docker compose up db -d -# 4. Open the app +# 4. First-run only: apply the schema and create your user +docker compose --profile setup run --rm setup + +# 5. Start the app +docker compose up app -d + +# 6. Open the app open http://localhost:3000 ``` @@ -65,8 +70,7 @@ docker compose down docker compose down -v # Re-seed after a wipe -docker compose exec app npx prisma db push -docker compose exec app npx prisma db seed +docker compose --profile setup run --rm setup # Check health curl http://localhost:3000/api/health diff --git a/docker-compose.yml b/docker-compose.yml index 4db5dc8..9f3a56c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,5 +33,23 @@ services: retries: 3 start_period: 60s + # First-run setup: applies the schema and seeds the user. + # Uses the builder stage so all dev tools (prisma CLI, tsx, bcryptjs) are available. + # Run once with: docker compose --profile setup run --rm setup + setup: + build: + context: . + target: builder + command: sh -c "npx prisma db push && npx prisma db seed" + environment: + DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} + SEED_EMAIL: ${SEED_EMAIL} + SEED_PASSWORD: ${SEED_PASSWORD} + depends_on: + db: + condition: service_healthy + profiles: + - setup + volumes: postgres_data: