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.

Contents
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.
Where it runs
Drydock is a self-hosted deploy portal that wires a repo to AWS from one manifest:
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 forprisma generate.NODE_ENVandPORTcome from the image and task definition, since ECS rejects duplicates. - Edge: Caddy terminates TLS and passes websockets through.
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):
- buildx the arm64 image (GHA layer cache), push to ECR tagged with the SHA
- Register a new task definition revision
- Run pre-deploy as a one-off task; fail on non-zero exit
- Update the service; wait for
services-stable
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; fiA 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:
## 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):
git worktree addat the exact SHAbun install --frozen-lockfilebun run buildmigrate deployagainst a throwaway databaseNODE_ENV=production bun run start- A real
/playwalk 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:
// 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'))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:
- A finished feature (agent done,
updates.mdentry and feature doc written) is merged or ported in bun run typecheck,bun run test,bun run buildon exactly that treegit 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
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) |
Related posts
- One process, one port, forty players: why deploying this is one container
- Forty players, one room: the load a deploy has to drain
- Testing an ARPG that agents wrote: what
bun run testchecks before a release - How Duskbound was built: the orchestration this process sits inside