feat(deploy): auto-run db migrations + seed on stack deploy
Add a migrator Dockerfile target (drizzle-kit migrate + tier-definitions seed, both idempotent) and wire it as a one-shot compose service that web waits on via service_completed_successfully. No more manual exec step after first deploy — runs safely on every redeploy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+5
-7
@@ -29,14 +29,12 @@ OPENROUTER_API_KEY=
|
||||
5. Deploy the stack. Portainer builds `web` from the repo's root `Dockerfile` (see `build:` in compose.prod.yml) — no separate image push needed.
|
||||
6. Enable GitOps updates (webhook or polling) on the stack if you want redeploy-on-push.
|
||||
|
||||
## First deploy: run migrations + seed
|
||||
## Migrations + seed
|
||||
|
||||
Compose does not auto-migrate. After the stack is up, exec into the `web` container once (or run a one-off container against the same network) with `DATABASE_URL` set, then:
|
||||
|
||||
```bash
|
||||
pnpm db:migrate
|
||||
pnpm db:seed # tier definitions — first deploy only
|
||||
```
|
||||
Handled automatically. The `migrate` service builds from the `migrator` Dockerfile target,
|
||||
runs `drizzle-kit migrate` then the tier-definitions seed, and exits; `web` waits for it to
|
||||
complete successfully before starting (`depends_on: migrate: condition: service_completed_successfully`).
|
||||
Both are idempotent — safe to re-run on every stack redeploy, not just the first one.
|
||||
|
||||
## Traefik (separate LXC, file provider)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user