chore: 添加 Docker 打包和 Compose 编排支持

This commit is contained in:
2026-04-02 02:43:21 +08:00
parent 9175909033
commit ed770909ef
4 changed files with 74 additions and 0 deletions
+11
View File
@@ -23,6 +23,9 @@ bun run db:generate # Generate migration SQL files (for production)
bun run db:migrate # Apply migrations (production deployment)
bun run db:studio # Drizzle Studio GUI
bun test path/to/test.ts # Run single test (not yet configured)
docker compose up --build # Build image & start app + postgres
docker compose up -d # Start in background (detached)
docker compose down # Stop and remove containers
```
## Code Style
@@ -118,6 +121,14 @@ const handler = new RPCHandler(router, {
**DON'T:** `npm`/`npx`/`node`/`yarn`/`pnpm` | Edit `routeTree.gen.ts` | `as any`/`@ts-ignore`/`@ts-expect-error` | Commit `.env` | Empty catch blocks | Import from `drizzle-zod` | RQBv1 callback-style API | `drizzle-orm/bun-sql` driver | Pass `schema` to `drizzle()` | Import `os` from `@orpc/server` in middleware (use `@/server/api/server`) | Leave docs out of sync
## Docker
- **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
- **Env**: `DATABASE_URL` set in `compose.yaml` pointing to the `db` service
## Git Workflow
1. Make changes → 2. `bun run fix` → 3. `bun run typecheck` → 4. `bun run dev` (test) → 5. Commit