Skip to content

fix(docker): auto-run prisma db push on web container start (Closes #6)#16

Merged
hacka0wi merged 1 commit into
mainfrom
fix/6-docker-compose-auto-migrate
May 7, 2026
Merged

fix(docker): auto-run prisma db push on web container start (Closes #6)#16
hacka0wi merged 1 commit into
mainfrom
fix/6-docker-compose-auto-migrate

Conversation

@hacka0wi

@hacka0wi hacka0wi commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

docker compose up -d against an empty Postgres was fatal-failing on the engine with relation "schedulers" does not exist because nothing in the compose stack runs the Prisma migration.

This PR adds a startup wrapper to the web container that runs npx prisma db push before exec'ing into Next.js. The k8s deployment continues to use its own init container (untouched); this just covers the docker-compose / single-host path.

Repro (before this PR)

```bash
git clone --branch v0.1.2 https://github.com/EnterpriseX-Platform/RunLoop runloop-test
cd runloop-test && cp .env.example .env
scripts/gen-secrets.sh >> .env
docker compose up -d
docker compose logs runloop-engine

{"level":"fatal","error":"failed to load schedulers: failed to query schedulers:

ERROR: relation "schedulers" does not exist (SQLSTATE 42P01)"}

```

The web container would happily serve the login page, but every API call would hit a dead engine.

Fix

apps/runloop/docker-entrypoint.sh:

```sh
if [ "$SKIP_DB_MIGRATE" != "true" ]; then
npx prisma db push --skip-generate --accept-data-loss
fi
exec node server.js
```

prisma db push is idempotent — repeated runs against an in-sync schema cost ~400 ms and make no changes, so leaving this on permanently is fine for restarts.

SKIP_DB_MIGRATE=true opt-out is there for ops setups that prefer timing migrations externally (blue/green deploys with a coordinated migration job).

Closes

Closes #6 — that issue was about validating docker compose up on a clean VM. It validated negatively; this PR makes it pass.

Test plan

  • docker build apps/runloop succeeds (verified locally, 53 s with cache)
  • Image inspects with ENTRYPOINT [/app/docker-entrypoint.sh]
  • After this PR, docker compose up -d against a fresh volume produces healthy engine + working login on :3000/runloop/login
  • CI green

 #6)

`docker compose up -d` against an empty Postgres was fatal-failing on
the engine startup with `relation "schedulers" does not exist` because
nothing in the compose stack ran the Prisma migration. The k8s
deployment uses a real init container for this; for the docker-compose
/ single-host install path we run the same `prisma db push` from a
shell wrapper before exec'ing into Next.js.

Verified by cloning v0.1.2 fresh, `docker compose up -d`, and watching
the engine fatal-crash. With the wrapper the engine starts clean against
the migrated DB.

Opt-out via `SKIP_DB_MIGRATE=true` for ops setups that prefer to time
migrations externally (blue/green deploys, etc.).
@hacka0wi hacka0wi merged commit b6f9082 into main May 7, 2026
8 checks passed
@hacka0wi hacka0wi deleted the fix/6-docker-compose-auto-migrate branch May 7, 2026 17:56
hacka0wi added a commit that referenced this pull request May 8, 2026
#16 fixes a critical first-install bug: docker compose up against an
empty Postgres now actually boots instead of fatal-crashing the engine
on missing tables. #17 adds the README-hero GIF tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify 'docker compose up' on a clean VM (T-7 launch checklist)

1 participant