refactor: 改用 Nitro 插件实现启动时数据库迁移

This commit is contained in:
2026-04-02 03:42:45 +08:00
parent 5de4d5f940
commit 77b3484415
6 changed files with 34 additions and 13 deletions
+2 -2
View File
@@ -125,8 +125,8 @@ const handler = new RPCHandler(router, {
- **Dockerfile**: Multi-stage — `oven/bun:1` (build + compile) → `gcr.io/distroless/cc-debian13:nonroot` (runtime)
- **Runtime**: Bun-compiled standalone binary (glibc-linked, requires `cc` distroless variant)
- **Compose**: `app` (port 3000) + `postgres:17-alpine` (port 5432) with health check
- **Migrations**: Run separately — `bun run db:push` (dev) or `bun run db:migrate` (prod) against the compose DB
- **Compose**: `app` + `db` with health check dependency
- **Migrations**: Nitro plugin runs `migrate()` at server startup (see `src/server/plugins/migrate.ts`)
- **Env**: `DATABASE_URL` set in `compose.yaml` pointing to the `db` service
## Git Workflow