Dough Git

commit

aaaa

commit
7c03b34f26b07dca7fcde4aa8065eee5fc965310
author
Clove Twilight <[email protected]>
date
2026-09-05 15:55

diff --git a/.env.example b/.env.example
index 5a03791..4e0d349 100644
--- a/.env.example
+++ b/.env.example
@@ -70,13 +70,3 @@ BETA_ALLOWED_DISCORD_IDS=
 # server-side, so rotation invalidates them rather than corrupting them.
 SESSION_SECRET=
 
-# --- published images ----------------------------------------------------
-# Only needed when running with docker-compose.prod.yml, which pulls prebuilt
-# images instead of compiling on the server. IMAGE_BASE is the Docker Hub
-# account and name WITHOUT the `-api` / `-web` suffix the overlay appends; no
-# registry host is needed, since Docker Hub is the default.
-IMAGE_BASE=
-# `latest` moves on every push to main. Pin an immutable tag in production --
-# `sha-abc1234`, a released `1.2.3`, or `1.2.3@sha256:...` -- so a restart
-# cannot quietly change what is running.
-IMAGE_TAG=latest
diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml
index d68ae47..b6da3c1 100644
--- a/.github/workflows/images.yml
+++ b/.github/workflows/images.yml
@@ -7,11 +7,10 @@ name: Publish images
 # Images are built for amd64 and arm64: most VPS hosts are amd64, Apple Silicon
 # is arm64, and one manifest serves both.
 #
-# Requires two repository secrets:
-#   DOCKERHUB_USERNAME  the account the images live under
-#   DOCKERHUB_TOKEN     an access token from Docker Hub → Account settings →
-#                       Personal access tokens, with Read & Write scope.
-#                       An access token, never the account password.
+# Requires one repository secret, DOCKERHUB_TOKEN: an access token from
+# Docker Hub → Account settings → Personal access tokens, with Read & Write
+# scope. An access token, never the account password — a token is scoped and can
+# be revoked on its own.
 
 on:
   push:
@@ -20,9 +19,9 @@ on:
   workflow_dispatch:
 
 env:
-  # Docker Hub image names are `account/name`, so the repository name cannot be
-  # used directly — it already contains a slash.
-  IMAGE_NAME: pkviewer
+  # The Docker Hub account. Not a secret: it is half of every published image
+  # name, and docker-compose.yml names it too.
+  DOCKERHUB_USER: doughmination
 
 jobs:
   build:
@@ -48,14 +47,14 @@ jobs:
       - name: Sign in to Docker Hub
         uses: docker/login-action@v3
         with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          username: ${{ env.DOCKERHUB_USER }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
       - name: Work out tags
         id: meta
         uses: docker/metadata-action@v5
         with:
-          images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}-${{ matrix.name }}
+          images: ${{ env.DOCKERHUB_USER }}/pkviewer-${{ matrix.name }}
           tags: |
             # A moving pointer for convenience, and immutable tags to pin to.
             type=raw,value=latest,enable={{is_default_branch}}
diff --git a/apps/web/test/docker.test.ts b/apps/web/test/docker.test.ts
index 018dabe..37263b5 100644
--- a/apps/web/test/docker.test.ts
+++ b/apps/web/test/docker.test.ts
@@ -56,40 +56,67 @@ describe("container toolchain", () => {
     expect(api).not.toMatch(/^\s+ports:/m);
   });
 
-  test("the web tier publishes only to loopback", () => {
+  // Published on every interface deliberately: the proxy is not on this host's
+  // loopback. Docker bypasses ufw, so nothing here can enforce the boundary --
+  // this only pins the port the proxy is configured against.
+  test("the web tier publishes 3000", () => {
     const compose = readFileSync(join(root, "docker-compose.yml"), "utf8");
-    expect(compose).toContain('"127.0.0.1:3000:3000"');
+    expect(compose).toContain('"3000:3000"');
   });
 });
 
 /**
- * The publish workflow and the production overlay have to agree on image names,
- * and nothing else connects them: CI pushes `USER/pkviewer-api`, the server
- * pulls whatever the overlay spells. Rename one and the other keeps working
- * right up until a deploy pulls a tag that was never published.
+ * The publish workflow and compose have to agree on image names, and nothing
+ * else connects them: CI pushes `doughmination/pkviewer-api`, the server runs
+ * whatever compose spells. Rename one and the other keeps working right up
+ * until a deploy pulls a tag that was never published.
  */
 describe("published images", () => {
   const workflow = readFileSync(join(root, ".github/workflows/images.yml"), "utf8");
-  const overlay = readFileSync(join(root, "docker-compose.prod.yml"), "utf8");
+  const compose = readFileSync(join(root, "docker-compose.yml"), "utf8");
+  // Only the services block: top-level `volumes:` also holds two-space keys.
+  const services = compose.slice(compose.indexOf("services:") + 9).split(/^\S/m)[0]!;
 
+  const account = workflow.match(/DOCKERHUB_USER: (\S+)/)?.[1];
   // Just the build matrix: `- name:` also introduces every workflow step.
   const matrix = workflow.slice(workflow.indexOf("include:")).split(/^ {4}\w/m)[0]!;
-  const built = [...matrix.matchAll(/- name: ([\w-]+)$/gm)].map((m) => m[1]!);
-  const pulled = [...overlay.matchAll(/image: \$\{IMAGE_BASE[^}]*\}-([\w-]+):/g)].map((m) => m[1]!);
+  const built = [...matrix.matchAll(/- name: ([\w-]+)$/gm)].map(
+    (m) => `${account}/pkviewer-${m[1]!}`,
+  );
+  const run = [...services.matchAll(/image: (\S+?):latest$/gm)].map((m) => m[1]!);
 
-  test("CI builds an image for every service the overlay pulls", () => {
+  test("CI publishes exactly the images compose runs", () => {
     // Both sides come from regexes, so an empty match on both would otherwise
     // agree vacuously.
     expect(built.length).toBeGreaterThan(0);
-    expect(new Set(built)).toEqual(new Set(pulled));
+    expect(new Set(built)).toEqual(new Set(run));
   });
 
-  test("the overlay pulls an image for every service compose defines", () => {
-    const compose = readFileSync(join(root, "docker-compose.yml"), "utf8");
-    // Only the services block: top-level `volumes:` also holds two-space keys.
-    const block = compose.slice(compose.indexOf("services:") + 9).split(/^\S/m)[0]!;
-    const services = [...block.matchAll(/^ {2}([\w-]+):$/gm)].map((m) => m[1]!);
-    expect(new Set(pulled)).toEqual(new Set(services));
+  test("every service runs a published image", () => {
+    const names = [...services.matchAll(/^ {2}([\w-]+):$/gm)].map((m) => m[1]!);
+    expect(run).toHaveLength(names.length);
+  });
+
+  // Compose runs images, it does not build them. A `build:` section would let a
+  // server quietly compile whatever source is lying around instead of running
+  // the pinned image, which is the failure this whole arrangement avoids.
+  test("compose never builds", () => {
+    expect(services).not.toContain("build:");
+    expect(services).not.toContain("dockerfile:");
+  });
+
+  // A pinned tag is only a pin if a restart actually fetches it.
+  test("every service pulls on every start", () => {
+    expect([...services.matchAll(/^ {4}pull_policy: always$/gm)]).toHaveLength(run.length);
+  });
+
+  // Nothing about which image runs is configurable, so there is no server-side
+  // variable that can drift from what CI publishes.
+  test("image references are fully literal", () => {
+    expect(run.length).toBeGreaterThan(0);
+    for (const line of services.match(/^ {4}image: .*$/gm) ?? []) {
+      expect(line).not.toContain("$");
+    }
   });
 
   // A password would work and would be wrong: a token is scoped and can be
diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml
deleted file mode 100644
index 5498072..0000000
--- a/docker-compose.prod.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-# Running from published images instead of building on the server.
-#
-#   docker compose -f docker-compose.yml -f docker-compose.prod.yml pull
-#   docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
-#
-# This overlay replaces the `build:` in docker-compose.yml with an `image:`, so
-# the server pulls what CI already built and tested rather than compiling. Every
-# other setting — the unpublished API port, the loopback web binding, the data
-# volume — comes from the base file unchanged.
-#
-# Set IMAGE_BASE and IMAGE_TAG in .env, for example:
-#   IMAGE_BASE=yourdockerhubuser/pkviewer
-#   IMAGE_TAG=latest
-#
-# IMAGE_BASE is the Docker Hub account and name without the `-api` / `-web`
-# suffix, which this file appends. No registry host is needed: Docker Hub is the
-# default, so `user/pkviewer` and `docker.io/user/pkviewer` mean the same thing.
-#
-# Pin IMAGE_TAG to a released version rather than `latest` once there is one, so
-# a restart cannot quietly change what is running. The publish workflow tags
-# every build with a short commit sha as well as semver, so there is always
-# something immutable to pin to.
-
-services:
-  api:
-    image: ${IMAGE_BASE:?set IMAGE_BASE in .env}-api:${IMAGE_TAG:-latest}
-    build: !reset null
-    pull_policy: always
-
-  web:
-    image: ${IMAGE_BASE:?set IMAGE_BASE in .env}-web:${IMAGE_TAG:-latest}
-    build: !reset null
-    pull_policy: always
diff --git a/docker-compose.yml b/docker-compose.yml
index 0aa75cf..de1f838 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,19 +1,29 @@
 # pkviewer, two containers.
 #
-#   docker compose up -d --build
-#
 # The split mirrors the architecture rather than fighting it: the API is the
 # only process that opens SQLite, so there is exactly one writer, and the web
 # tier renders and proxies.
 #
-# Configuration comes from a .env file beside this one. Nothing secret is baked
-# into an image.
+#   docker compose pull && docker compose up -d
+#
+# This file only ever RUNS images; it never builds them. Images are built and
+# published by .github/workflows/images.yml, so what runs is always something
+# CI produced from a known commit, and the server needs no toolchain, no source
+# checkout and no spare CPU. To build one by hand:
+#
+#   docker build -f docker/api.Dockerfile .
+#
+# Always `latest`: a `docker compose pull` is the whole upgrade, and there is no
+# version to keep in step anywhere. Configuration comes from the .env file
+# beside this one (or point elsewhere with `--env-file`); nothing secret is
+# baked into an image.
 
 services:
   api:
-    build:
-      context: .
-      dockerfile: docker/api.Dockerfile
+    image: doughmination/pkviewer-api:latest
+    # Always: `latest` is a moving tag, so a restart must go and fetch it
+    # rather than reuse whatever is in the local image cache.
+    pull_policy: always
     restart: unless-stopped
     # NOTE: no `ports:`. The API is internal — the browser never calls it, the
     # web tier proxies everything. Publishing 3001 would put the management API
@@ -56,15 +66,24 @@ services:
       start_period: 10s
 
   web:
-    build:
-      context: .
-      dockerfile: docker/web.Dockerfile
+    image: doughmination/pkviewer-web:latest
+    # Always: `latest` is a moving tag, so a restart must go and fetch it
+    # rather than reuse whatever is in the local image cache.
+    pull_policy: always
     restart: unless-stopped
-    # The only thing reachable from outside. Bind to loopback and put a TLS
-    # terminating proxy in front; `127.0.0.1:3000:3000` rather than `3000:3000`
-    # keeps it off the host's public interfaces.
+    # The only thing reachable from outside. Published on every interface, not
+    # just loopback, because the reverse proxy is not on this host's loopback.
+    #
+    # This is NOT firewalled by ufw or firewalld: Docker publishes through
+    # DOCKER-USER and nat PREROUTING, which run before the INPUT chain those
+    # tools manage, so `ufw deny 3000` has no effect. Whatever keeps 3000 off
+    # the public internet has to live outside this file — a cloud security
+    # group, or an explicit DOCKER-USER rule.
+    #
+    # Reaching it over plain http also breaks sign-in: cookies are `__Host-`
+    # and `Secure`, so only the https origin can hold a session.
     ports:
-      - "127.0.0.1:3000:3000"
+      - "3000:3000"
     environment:
       NODE_ENV: production
       PORT: "3000"
diff --git a/docs/decisions.md b/docs/decisions.md
index 9ec6953..b11bba4 100644
--- a/docs/decisions.md
+++ b/docs/decisions.md
@@ -517,21 +517,35 @@ belongs to someone else are indistinguishable — and every management page is
 writer, so it is the only container with the data volume. It is `expose`d to the
 compose network and never `ports:`-published: the browser reaches it only
 through the web tier's proxy, so publishing 3001 would put the management API on
-the host network. The web tier binds `127.0.0.1:3000` and a TLS-terminating
-reverse proxy sits in front. Guarded by `apps/web/test/docker.test.ts`.
-
-**D2. Images are built in CI, not on the server.** `.github/workflows/images.yml`
-publishes `USER/pkviewer-api` and `USER/pkviewer-web` to **Docker Hub** for
-amd64 and arm64; `docker-compose.prod.yml` swaps `build:` for `image:` and
-changes nothing else. Docker Hub over GHCR was the owner's preference — both
-registries pin identically, so this was not a technical constraint. CI
-authenticates with a scoped access token in `DOCKERHUB_TOKEN`, never a password.
-
-**D3. Every build gets an immutable tag.** `latest` moves; `sha-<short>` and
-semver tags do not. Production pins one of the immutable ones so a restart, or
-`pull_policy: always`, cannot silently change what is running. A test asserts
-the workflow's build matrix and the overlay's image names cannot drift apart,
-because nothing else connects them and the failure only surfaces at deploy time.
+the host network. The web tier publishes `3000:3000` on every interface — the
+reverse proxy is not on the host's loopback, so a loopback bind could not reach
+it — and TLS terminates at that proxy. Docker publishes ahead of the chain `ufw`
+manages, so keeping 3000 off the public internet is a host or security-group
+concern that compose cannot enforce. Guarded by `apps/web/test/docker.test.ts`.
+
+**D2. Compose runs images, it never builds them.** There is one
+`docker-compose.yml` with no `build:` section at all;
+`.github/workflows/images.yml` publishes `doughmination/pkviewer-api` and
+`doughmination/pkviewer-web` to **Docker Hub** for amd64 and arm64. Building on the
+server costs CPU it has none of and, worse, makes the running code a function of
+whatever source happens to be checked out rather than of a known commit. An
+overlay file offering both modes was tried and rejected as a second thing to
+keep in step. Docker Hub over GHCR was the owner's preference — both registries
+pin identically, so this was not a technical constraint. CI authenticates with a
+scoped access token in `DOCKERHUB_TOKEN`, never a password.
+
+**D3. Compose runs `latest`, and every start pulls.** The image names and the
+tag are written into `docker-compose.yml` literally — nothing about which image
+runs is configurable, so there is no server-side variable that can drift from
+what CI publishes, and a deploy is `pull && up -d` with nothing to edit.
+`pull_policy: always` is what makes a moving tag work at all: without it a
+restart reuses the local image cache. The owner chose this over pinning an
+immutable tag, having weighed it twice; CI still publishes `sha-<short>` and
+semver tags, so a rollback means retagging one of those as `latest` by hand.
+The accepted costs are that a bad `main` reaches the server on the next pull,
+and that the running version is recorded nowhere. A test asserts CI publishes
+exactly the images compose runs, because nothing else connects those two files
+and the failure only surfaces at deploy time.
 
 **D4. Origins are configuration, never baked into an image.** The web image
 builds with `http://build.invalid` placeholders precisely so that a value
diff --git a/docs/deployment.md b/docs/deployment.md
index da4a585..d684999 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -111,6 +111,9 @@ SIGNUP_ENABLED=true
 BETA_ALLOWED_DISCORD_IDS=<your Discord user id>
 ```
 
+Under Docker, `INTERNAL_API_ORIGIN` and `DATABASE_PATH` are set by compose
+(`http://api:3001` and `/data/pkviewer.db`) rather than by `.env`.
+
 Configuration is validated at startup and a missing or malformed value fails
 loudly, naming the variable. It never falls back to an insecure default in
 production.
@@ -156,9 +159,20 @@ backing up.**
 
 ## Running with Docker
 
+`docker-compose.yml` runs images; it never builds them. Images are built and
+published by `.github/workflows/images.yml`, so what runs on the server is
+always something CI produced from a known commit — the server needs no
+toolchain, no source checkout and no spare CPU, and there is no question of
+which working copy the running code came from.
+
+Which images run is not configurable: `docker-compose.yml` names
+`doughmination/pkviewer-api:latest` and `doughmination/pkviewer-web:latest`
+outright. On the server, that file and `.env` are all that is needed:
+
 ```bash
 cp .env.example .env      # fill in the production values
-docker compose up -d --build
+docker compose pull
+docker compose up -d
 ```
 
 Two containers, mirroring the architecture: `api` owns SQLite and is the only
@@ -166,19 +180,18 @@ writer; `web` renders and proxies. Configuration comes from `.env` at run time 
 nothing secret is baked into an image, and no origin is compiled in, so moving
 domains stays a config change.
 
-**The images pin Bun to the version that wrote `bun.lock`.** A frozen install
-cannot satisfy a lockfile written by a newer Bun, so an image pinned behind the
-lockfile fails on the server while building fine locally. When you upgrade Bun,
-update `docker/*.Dockerfile` in the same commit — a test asserts they match.
-
-Three details in `docker-compose.yml` are deliberate:
+Four details in `docker-compose.yml` are deliberate:
 
 - **`api` has no `ports:`, only `expose:`.** Publishing 3001 would put the
   management API straight onto the host network, reachable without going through
   the web tier. It is addressable only as `http://api:3001` from inside.
-- **`web` publishes to `127.0.0.1:3000`, not `0.0.0.0:3000`.** Put a
+- **`web` publishes `3000:3000`, on every interface.** The reverse proxy is not
+  on this host's loopback, so a loopback-only bind cannot reach it. Put a
   TLS-terminating proxy in front; the container itself should not be the thing
-  facing the internet.
+  facing the internet, and keeping it off the public internet is now the host's
+  job rather than compose's — see below.
+- **`pull_policy: always`.** A pinned tag is only a pin if a restart actually
+  fetches it rather than reusing whatever is in the local image cache.
 - **The named volume `pkviewer-data` is the whole of pkviewer's state.** Back
   that up; see below.
 
@@ -192,87 +205,115 @@ docker compose exec api sh -c \
 or more simply, stop the stack and copy the volume. Never `cp` a live WAL
 database.
 
-## Running from published images
+### Port 3000 is not covered by ufw
+
+Docker publishes ports through the `DOCKER-USER` chain and `nat PREROUTING`,
+both of which run **before** the `INPUT` chain that `ufw` and `firewalld`
+manage. `ufw deny 3000` therefore does nothing: the port stays open to anything
+that can route to the host.
 
-Building on the server costs CPU it usually has none of, and means the running
-code was compiled somewhere unversioned. `.github/workflows/images.yml` builds
-both images for amd64 and arm64 on every push to `main` and publishes them to
-Docker Hub, so the server pulls instead.
+Restrict it outside this file, with whichever applies:
 
-The workflow needs two repository secrets, under Settings → Secrets and
-variables → Actions:
+- a cloud provider security group allowing 3000 only from the proxy's address;
+- an explicit rule, e.g.
+  `iptables -I DOCKER-USER -p tcp --dport 3000 ! -s <proxy-ip> -j DROP`.
 
-| Secret | Value |
-| --- | --- |
-| `DOCKERHUB_USERNAME` | the Docker Hub account the images live under |
-| `DOCKERHUB_TOKEN` | a personal access token with Read & Write scope, from Docker Hub → Account settings → Personal access tokens |
+Leaving 3000 open to the internet is not a data leak — it serves the same pages
+the proxy does — but it is reachable over plain http, where `__Host-` `Secure`
+cookies cannot be set, so sign-in fails and the origin in links is wrong. Check
+it with `curl http://<public-ip>:3000/` from off the host.
+
+## Publishing images
+
+`.github/workflows/images.yml` builds both images for amd64 and arm64 on every
+push to `main` and publishes them to Docker Hub.
+
+It needs one repository secret, under Settings → Secrets and variables →
+Actions: **`DOCKERHUB_TOKEN`**, a personal access token with Read & Write scope,
+from Docker Hub → Account settings → Personal access tokens.
 
 Use an access token, never the account password: a token is scoped, listed, and
 revocable on its own without changing the password everywhere else it is used.
+The account name is not a secret — it is half of every published image name —
+so it sits in the workflow as `DOCKERHUB_USER`.
 
-The two repositories — `USER/pkviewer-api` and `USER/pkviewer-web` — are created
-by the first successful push. They are public by default; make them private in
-Docker Hub if that is wanted, and then `docker login` on the server before
-pulling.
+The two repositories — `doughmination/pkviewer-api` and
+`doughmination/pkviewer-web` — are created by the first successful push. They
+are public by default; make them private in Docker Hub if that is wanted, and
+then `docker login` on the server before pulling.
 
-Add to `.env`:
+**The images pin Bun to the version that wrote `bun.lock`.** A frozen install
+cannot satisfy a lockfile written by a newer Bun, so an image pinned behind the
+lockfile fails while building fine locally. When you upgrade Bun, update
+`docker/*.Dockerfile` in the same commit — a test asserts they match.
 
+To build an image by hand, from the repository root:
+
+```bash
+docker build -f docker/api.Dockerfile .
+docker build -f docker/web.Dockerfile .
 ```
-IMAGE_BASE=USER/pkviewer
-IMAGE_TAG=latest
-```
 
-`IMAGE_BASE` omits the `-api` and `-web` suffix, which the overlay appends, and
-needs no registry host — Docker Hub is the default, so `USER/pkviewer` and
-`docker.io/USER/pkviewer` mean the same thing.
+### Tags
+
+Every build is published under several tags:
+
+| Tag | Moves | Notes |
+| --- | --- | --- |
+| `latest` | yes, on every push to `main` | what compose runs |
+| `sha-abc1234` | never | the exact commit |
+| `1.2.3` | never | a release, from a `v1.2.3` git tag |
+| `1.2` | yes, within a minor series | a patch series |
+
+Compose runs `latest` and nothing else, so a `docker compose pull` is the whole
+upgrade and there is no version to keep in step between the repository and the
+server. The cost is that a bad `main` reaches the server on the next pull, and
+that the running version is not recorded anywhere.
 
-Then:
+To go back, pull an older tag under the `latest` name by hand:
 
 ```bash
-docker compose -f docker-compose.yml -f docker-compose.prod.yml pull
-docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
+docker pull doughmination/pkviewer-api:sha-abc1234
+docker tag doughmination/pkviewer-api:sha-abc1234 doughmination/pkviewer-api:latest
+docker compose up -d --no-deps api      # without `pull`, which would undo it
 ```
 
-The overlay swaps `build:` for `image:` and changes nothing else — the
-unpublished API port, the loopback web binding and the data volume all still
-come from the base file.
+That holds until the next `docker compose pull`, so it buys time to fix `main`
+rather than being a place to sit.
 
-### Pinning
+### Deploying a new image
 
-Every build is published under several tags:
+```bash
+docker compose pull
+docker compose up -d
+```
 
-| Tag | Moves | Use |
-| --- | --- | --- |
-| `latest` | yes, on every push to `main` | convenience only |
-| `sha-abc1234` | never | pin to an exact commit |
-| `1.2.3` | never | pin to a release, from a `v1.2.3` git tag |
-| `1.2` | yes, within a minor series | patch updates without a version bump |
+Nothing to edit: CI publishes `latest`, `pull` fetches it, `up -d` recreates
+whichever containers changed.
 
-Pin `IMAGE_TAG` to one of the immutable tags in production. `latest` means a
-`docker compose pull` — or an automatic restart with `pull_policy: always` —
-can silently change what is running, and there is then no record of what was
-running when something broke.
+Migrations run on API start, inside the one process that owns the database, and
+are forward-only. Test them against a copy of production data before deploying a
+schema change — retagging an older image does not roll a migration back.
 
-For an exact, unfakeable pin, use a digest instead of a tag: `docker buildx
-imagetools inspect USER/pkviewer-api:1.2.3` prints one, and
-`IMAGE_TAG=1.2.3@sha256:…` works in the overlay.
+## Working locally
 
-## Deploying a change
+Deployment goes through images, but the checks that gate one still run here:
 
 ```bash
 bun install
 bun run check          # guard, typecheck, tests
 bun run build
-# restart both processes; migrations run on API start
 ```
 
-Migrations are forward-only. Test them against a copy of production data before
-deploying a schema change.
-
 The production build writes to `.next-prod` and the dev server uses `.next`, so
 building never disturbs a running development server. `NEXT_DIST_DIR` overrides
 the directory if a deployment needs it elsewhere.
 
+Running the two processes directly — `bun run dev` — needs the same environment
+variables as the containers, minus the image ones. `API_HOST` defaults to
+`127.0.0.1` outside Docker; the images set it to `0.0.0.0` so the web container
+can reach the API over the compose network.
+
 ## Moving domains
 
 Under the rules above this is configuration, with two things that are not free: