production is a static build behind nginx, not a process

The site's own build script says it outright: "The public site is not served by
Bun in production — it is a directory of files behind nginx. Output: dist/."
So production has no port, nothing to restart, and nothing that can crash at
three in the morning. It is built or stale, and served or not served.

Showing it as a pm2 process was showing something that does not exist, and its
Start button could only ever have failed. It now has Build, Serve and Stop, and
the two states are reported separately — a build can succeed while nothing
serves it, and a container can serve a directory built weeks ago. They fail
independently and are fixed differently.

The container exists because nginx could not see the files. NPM mounts only its
own /data and /etc/letsencrypt, and there is no other nginx on the box. The
alternatives were putting site files inside NPM's own volume, or editing NPM's
compose and restarting it — which takes every site on this machine down for a
moment. So: one nginx:alpine, dist mounted READ-ONLY, on NPM's own network with
NO published port. NPM reaches it by name, and nothing about the site is exposed
except through the proxy.

Recreated rather than restarted, for the same reason pm2 is: a container keeps
the mounts it was created with, so a root location changed here would be saved,
displayed, and still serving the old directory.

Domains follows. Production's forward target is a container NAME, not the docker
gateway that reaches a host process — and matching what already points at it
uses the full target rather than the port, since every other site behind this
NPM on port 80 would otherwise be listed as fofos's.

The compiler found the dead branches this left in startServer once production
could no longer reach it. Removed rather than left to read as though the case
were still possible.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-29 19:36:29 +01:00
co-authored by Claude Opus 5
parent 752c06d24a
commit 27f93d6e14
6 changed files with 472 additions and 22 deletions
+20 -9
View File
@@ -8,9 +8,19 @@ import { Block } from './Block';
import { Console } from './Console';
import { useFlash } from './useFlash';
import { ProxiesBlock } from './ProxiesBlock';
import { StaticBlock } from './StaticBlock';
/**
* The two servers that serve the site, under pm2.
* How the site is served: a development process, and a production build.
*
* ── They are not two of the same thing, and this stopped pretending ──
*
* Development is `bun --hot` under pm2 — a process with a port, an uptime and a restart count.
* Production is a directory of files behind nginx, which the site's own build script says outright: it
* has no port and nothing to restart. It is built or stale, served or not served.
*
* So production gets Build and a container. Showing it as a process was showing something that does not
* exist, and its Start button could only ever have failed.
*
* A block inside Administration rather than a section of its own: it is the same KIND of thing as the
* root location and the databases — this machine, not the site's content — and a nav row for one card
@@ -88,7 +98,8 @@ export const ServersBlock = () => {
setServers(
await clientRef.current.put<Server[]>('/fofos-admin/_config/servers', {
development: Number(dev),
production: Number(prod),
// Still sent because the API validates that the two differ. Nothing listens on it.
production: Number(prod || 3010),
}),
);
flash();
@@ -121,9 +132,8 @@ export const ServersBlock = () => {
}
};
const dirty =
dev !== String(servers?.find((s) => s.name === 'development')?.port ?? '') ||
prod !== String(servers?.find((s) => s.name === 'production')?.port ?? '');
// Only development has a port now. Production is a container on a docker network, publishing none.
const dirty = dev !== String(servers?.find((s) => s.name === 'development')?.port ?? '');
const row = (server: Server, value: string, onChange: (next: string) => void) => {
// pm2 saying `online` is not the same as the site answering — `bun --hot` stays alive after a
@@ -214,16 +224,17 @@ export const ServersBlock = () => {
>
{!servers ? null : (
<>
{servers.map((server) =>
server.name === 'development' ? row(server, dev, setDev) : row(server, prod, setProd),
)}
{servers.filter((server) => server.name === 'development').map((server) => row(server, dev, setDev))}
{/* Production, which is a build rather than a process — see StaticBlock. */}
<StaticBlock />
{error && <p className="text-xs text-destructive">{error}</p>}
<Console output={output} failed={failed} />
{dirty && (
<div className="flex justify-end border-t border-border pt-3">
<Button size="sm" onClick={() => void savePorts()} disabled={busy !== null || !dev || !prod}>
<Button size="sm" onClick={() => void savePorts()} disabled={busy !== null || !dev}>
{busy === 'ports' ? <Loader2 className="size-3.5 animate-spin" /> : <Check className="size-3.5" />}
Save ports
</Button>