nagaya

By Daniel Chiwuzoh

nagaya

Nagaya (長屋) is a Japanese row house: many households under one roof. This repo is that for my side projects. Every futari and ofuma site is configured here and only here. Nothing on the server side is set up by hand.

Before this, each project was set up on its own, built its own images where it ran, and had to be patched and backed up separately. Now there is one place to change things, one place to look when something breaks, and a much smaller bill.

The registry. sites.yaml declares every app, site, service, domain, memory limit, scheduled job and alert, along with the Node and nginx versions every app builds on. A TypeScript and zod renderer turns it into the Caddy config, the Docker Compose files, the crontab and a deploy plan. Adding a subdomain is an entry and a merge.

Terraform, split into modules, handles the rest:

  • Cloudflare zones, DNS records, certificates, WAF rules and email routing.
  • The GitHub Actions secrets each app repo needs to deploy.
  • Every pull request runs the renderer tests and prints the Terraform plan, so I can see what a change will do before merging it. Every merge applies it.

The nagaya CLI lives in bin/. It reads the rendered plan and makes Docker match it:

  • apply reconciles everything with the registry.
  • deploy pulls the images, prepares anything a new app needs, starts the services and health-checks them. If a check fails it rolls back to the previous version on its own, and rollback does the same by hand.
  • stg up and stg down start and stop a staging copy of an app or a single site, so staging only costs anything while I need it.
  • backup, restore and drill cover the data: nightly offsite backups, and a drill that restores the newest one into a scratch copy and compares it, so I know the backups actually work.
  • status and alerts for day-to-day checks.

Deploys. Each app's CI builds its images and pushes them to GHCR, so nothing compiles where the apps run. A push only rebuilds and restarts the services it actually changed.

Alerting. I get an email when something needs attention: one when a problem starts, a reminder while it lasts, and one when it clears.

  • Memory, swap, memory pressure and disk space, plus any process killed for running out of memory.
  • Certificates that are wrong, mismatched or close to expiring, and any site Cloudflare cannot reach.
  • A Node security release or nginx patch for the pinned versions. A sync job pushes version bumps into every app repo, so they all build on the same runtime.
  • Changes to Cloudflare's published IP ranges. A weekly GitHub workflow also opens a pull request with the new list.