ops: add migrate/seed/preflight compose profile for clean fresh setup

The portal database lives on an internal-only network and is not exposed to
the host, so `pnpm drizzle-kit migrate` and admin seeding cannot run from the
host. Add one-shot `ops`-profile services built from the builder stage that run
migrations, seed the first admin, and run the preflight smoke test against the
real env from inside the network. Share the app env via an x-portal-env anchor.

Update the runbook to use the new commands.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude committed 2026-08-10 23:14:02 +02:00
1 parent 6fc095a161
commit 013036ea81
2 files changed
+89 -20

No files matched your search

+18 -5
View File
@@ -68,15 +68,28 @@ When placing Nginx or Traefik in front of the portal:
---
## 5. Database Migrations
## 5. Database Migrations, Admin Seed, Preflight
Database schema migrations are managed via Drizzle Kit.
These one-shot tasks run in the `builder` stage on the internal network so they
can reach `portal-db` (which is not exposed to the host). They are grouped under
the `ops` compose profile and do not start with `docker compose up`.
- **Apply Migrations**:
- **Apply migrations** (run before starting a new app version):
```bash
pnpm drizzle-kit migrate
docker compose --profile ops run --rm migrate
```
- Migrations must be executed prior to starting a new app container version.
- **Seed the first admin** (override the command to pass credentials):
```bash
docker compose --profile ops run --rm seed \
pnpm tsx scripts/create-admin.ts admin@example.de "AdminPassword!" "Name"
```
- **Smoke-test env + connectivity** (DB, Better Auth, SMTP, Immich):
```bash
docker compose --profile ops run --rm preflight
```
Migrations and the admin seed must be executed after the database is healthy and
before the app is started for the first time.
---