Shipping it: Drydock, migrations and green SHAs

One arm64 ECS task behind Caddy, SSM secrets, migrations instead of db push, a release worktree that only pushes verified SHAs, and a SIGTERM path that saves every hero.

Two browser windows side by side, a Warden and a Stalker in the same Hollowmere instance with a shared party frame
Contents
  1. Where it runs
  2. The pipeline
  3. Domains and TLS
  4. Migrations, never db push
  5. Deploying under live players
  6. Only green code reaches master
  7. Hotfixes go the other way
  8. Verifying production
  9. By the numbers
  10. Related posts

Every push to master deploys, while up to ten agents edit the tree and a checkpoint commits their half-finished work every 20 minutes. Production went live at 14:34; seven deploys by 18:31, all green.

A day on one axis: start at 10:10, first commit at 11:59, auto-checkpoints every 20 minutes, and seven production deploys between 14:34 and 18:31
Seven deploys, all green, from gh run list. Checkpoints are ancestors in the history but never the commit a deploy built

Where it runs

Drydock is a self-hosted deploy portal that wires a repo to AWS from one manifest:

drydock.yaml (excerpt)YAML
name: gloamreach
kind: ssr          # ssr | static
runtime: bun        # bun | node
port: 4477
memory: 384        # MiB soft reservation (overrides size)
build: bun run build
start: bun run start
database: true      # provision Postgres + DATABASE_URL
prisma: true
predeploy: bun run db:deploy
domains:
  - duskboundga.me
  # plus the original gloamreach subdomain
dnsZone: duskboundga.me
  • Compute: one arm64 ECS task on a shared t4g.large, 384 MiB reserved, 1,152 MiB hard limit. The box had ~805 MiB free and a rolling deploy runs two tasks, so 384 is the largest reservation that still rolls.
  • Database: Postgres on the same host, database gloamreach (renaming it for a brand is all risk), reached over the Docker bridge; its URL in SSM.
  • Secrets: SSM parameters injected by ECS (DATABASE_URL, admin login, flags). The Dockerfile's only DB URL is a dummy for prisma generate. NODE_ENV and PORT come from the image and task definition, since ECS rejects duplicates.
  • Edge: Caddy terminates TLS and passes websockets through.
Deploy topology: git push to GitHub Actions to ECR to the pre-deploy task to the ECS update; and a request from the browser through Route53 and Caddy to the Bun process and Postgres, with SSM feeding the task env
Two paths through the same box. The pre-deploy task is the only thing that touches the schema
Dockerfile (generated by Drydock)Dockerfile
FROM oven/bun:1.3-alpine AS build
WORKDIR /app
COPY package.json bun.lock ./
COPY prisma ./prisma
COPY prisma.config.ts* ./
# ENV DATABASE_URL=<a dummy URL, only so prisma generate can run>
RUN bun install --frozen-lockfile
COPY . .
RUN bun run build
 
FROM oven/bun:1.3-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app /app
EXPOSE 4477
CMD ["sh", "-c", "bun run start"]

The runtime keeps dev dependencies so the Prisma CLI is there for migrations. One process serves SSR, tRPC and Colyseus on one port (architecture): no separate game server, no sticky sessions, no Redis.

The pipeline

.github/workflows/drydock.yml on an arm64 runner, AWS via OIDC (no stored keys):

  1. buildx the arm64 image (GHA layer cache), push to ECR tagged with the SHA
  2. Register a new task definition revision
  3. Run pre-deploy as a one-off task; fail on non-zero exit
  4. Update the service; wait for services-stable
.github/workflows/drydock.yml (pre-deploy step)Shell
TASK=$(aws ecs run-task --cluster drydock --task-definition "$TASKDEF" \
  --overrides '{"containerOverrides":[{"name":"app","command":["sh","-c","bun run db:deploy"]}]}' \
  --query 'tasks[0].taskArn' --output text)
aws ecs wait tasks-stopped --cluster drydock --tasks "$TASK"
EXIT=$(aws ecs describe-tasks --cluster drydock --tasks "$TASK" --query 'tasks[0].containers[0].exitCode' --output text)
if [ "$EXIT" != "0" ]; then echo "pre-deploy failed (exit $EXIT)"; exit 1; fi

A failed migration leaves the old task serving. Push to stable: 3 min 21 s to 6 min 56 s.

Domains and TLS

The game launched on a gloamreach subdomain in a zone Drydock already managed. After the rename, duskboundga.me became canonical: Drydock created its Route53 zone (dnsZone), the registrar points at it, and A records for both names hit the EC2 box. Caddy issues and renews both certificates automatically. Page, API and game socket share one origin: no CORS, no second cert, no cookie scoping. Both domains stay live.

Migrations, never db push

The template ran prisma db push before each deploy. The deploy agent replaced it before the first production push:

decisions.mdMarkdown
## 2026-09-27 — Prisma migrations (not db push) from here on
**Why:** characters must survive for years; `db push --accept-data-loss` can silently drop columns.
Baseline `0_init` generated from the schema and marked applied on the dev DB. Schema changes:
`bun run db:migrate --name <x>`; prod pre-deploy: `bun run db:deploy`.
**Rejected:** db push in prod (data loss risk).
  • db:deploy = prisma migrate deploy: committed files only, in order, never generate or reset
  • Five migrations after the baseline, all additive (endgame, rift_runs, admin, companions, items_database); four released
  • Additive means the old task survives the new schema during the roll
  • JSON columns go through zod (parseCharacter); a bad save is salvaged column by column, never a crashed join

The first release was proven from a clean tree (now in verify.md):

  1. git worktree add at the exact SHA
  2. bun install --frozen-lockfile
  3. bun run build
  4. migrate deploy against a throwaway database
  5. NODE_ENV=production bun run start
  6. A real /play walk over websockets, checking for asset 404s

Deploying under live players

A hero's authoritative state lives in the room until saved, so shutdown protects player data:

server.tsTypeScript
// Save everyone before exiting (Ctrl-C, drydock task stop).
const stop = (signal: string) => {
  log.info(`${signal} received, saving players…`)
  void game.shutdown().finally(() => process.exit(0))
}
process.once('SIGINT', () => stop('SIGINT'))
process.once('SIGTERM', () => stop('SIGTERM'))
server/game/index.tsTypeScript
const shutdown = () => {
  shuttingDown ??= (async () => {
    try {
      // Disconnects every client, so ZoneRoom.onLeave saves each character.
      await matchMaker.gracefullyShutdown()
      await stopAdminRecorder() // admin: close play sessions, flush events
      await stopItemTally() // items: flush drop / craft counters
      transport.shutdown()
    } catch (e) {
      log.error(`colyseus shutdown failed: ${formatError(e)}`)
    }
  })()
  return shuttingDown
}

SIGTERM → every client disconnected → each onLeave saves the stash, releases its lock and awaits the character's write queue → recorders flush → exit. Clients treat the drop as reconnecting: backoff from 600 ms, doubling to 8 s, up to six tries, landing in a fresh instance of the same zone at the saved position.

Only green code reaches master

The working tree is the agents'. Checkpoints (wip: auto-checkpoint HH:MM (agents in flight)) keep work recoverable within 20 minutes; some don't typecheck; none are releases. Releases come from a second worktree on a release/* branch:

Two worktrees: agents on master with checkpoints, a release worktree where finished features are merged and verified, then pushed to origin/master and through the Drydock pipeline
Nothing reaches origin/master except a release commit that has passed typecheck, tests and build
  1. A finished feature (agent done, updates.md entry and feature doc written) is merged or ported in
  2. bun run typecheck, bun run test, bun run build on exactly that tree
  3. git push origin <sha>:master, so what deploys is the verified commit even if the branch moved
Deploy (local) SHA Commit
14:34 e55a62d Drydock: sync deploy config
14:50 f4d1476 docs: deploy section, verify.md, updates entry
15:40 2e5ebc1 feat: gamepad controller support (backport for prod)
17:22 d5308f5 merge: prod controller backport + duskboundga.me domain into release
17:45 dca9bc5 fix: widen the waypoint panel so six act tabs fit
18:10 293b2d7 fix(balance): Act 1 Normal no longer lethal
18:31 a9db931 merge: companions, private worlds, party panel, admin console + login, rift tuning into release

Hotfixes go the other way

Urgent fixes are made on the known-good release branch, then ported back:

d3da86d fix(pad): detect Xbox BT pads before Sony token (from prod release)
1f1f48f fix(balance): Act 1 Normal no longer lethal (port of release 293b2d7)

Fixing on master would ship everyone's half-finished work or mean cherry-picking out of a moving tree. The balance fix was committed on release at 17:55 and deploying at 18:10.

Verifying production

verify.md — Production smokeShell
curl -s https://duskboundga.me/healthz        # {"status":"ok",…} (DB ping)
curl -s https://duskboundga.me/api/status     # JSON with online + rooms
curl -s -o /dev/null -w "%{http_code}" https://duskboundga.me/   # 200, valid cert
gh run list -L 3                              # latest run green

/healthz pings Postgres, so green means the task reaches the database. The third line checks TLS for free.

The multiplayer recipe: two isolated bx profiles create guests in production and walk into the Blighted Fields. Pass when both report the same roomId, both names appear in room.state.players, a monster dies to one of them, /api/status says online: 2, and neither has a failed request.

By the numbers

Deploys 7, all green; CI 3 min 21 s to 6 min 56 s
Time to first production ~4 h 25 min from session start (10:10 → 14:34), 2 h 35 min from first commit
Code ~105,000 lines of TS/TSX, generated files excluded
Migrations after baseline 5, all additive, 4 released
Memory 384 MiB reserved, 1,152 MiB limit, one shared t4g.large
Secrets in the repo none (gitignored .env locally, SSM in production)