The environments
Campfire runs in three environments on a developer's machine – local, dev, and prod – and they differ in one thing: what sits behind the back-end paths. All three serve the same origin, http://localhost:8000, with Caddy as the front door, so the web application and the shells never know which one is running (ADR 012). Neither does sign-in, whose cookies live on the app's own origin and whose round trip only completes on the host name ScoutID sends the browser back to (ADR 019). One origin everywhere keeps that from being three separate problems.
| Environment | Start with | The web application | /api/auth and /api/project | Sign-in |
|---|---|---|---|---|
| local | pnpm start:local | Vite, on the host | The mock, on the host | A persona picker |
| dev | pnpm start:dev | Vite, in a container | The real back-end, in containers | Real ScoutID, or a faked member |
| prod | pnpm start:prod | The built image | The real back-end, in containers | Real ScoutID |
The environment is a property of the running stack, not of the build. Nothing in the web application reads which one it is, and a start script frees port 8000 first, naming what held it, and reports the stack ready only once it answers through the front door.
The front door
Each environment's front door routes the same paths to different places. Every back-end has its own prefix under /api/, named for the service, and everything else is the web application's.
| Path | local | dev | prod |
|---|---|---|---|
/api/auth | The mock | The auth service | The auth service |
/api/project | The mock | The project API | The project API |
/__mock__ | The mock's ScoutID stand-in and control surface | – | – |
| Everything else | Vite on the host | Vite in a container | The image's own Caddy |
Dev and prod strip the prefix before a request reaches a service, because the real services serve their endpoints at their own root, as they do behind the deployed ingress. The mock serves every service at its full path, so local passes them through unchanged.
Everything about running Campfire lives in config/environments/, one folder per environment – a Caddyfile in each, and a compose.yaml besides for dev and prod. The folders duplicate rather than share, so each environment reads top to bottom on its own.
Local
Local is the everyday environment. It needs nothing beyond the machine and starts in seconds: Caddy on 8000, the mock on 8003, and Vite on 3000. The mock answers as the back-end services do, and serves a ScoutID stand-in whose sign-in page is a persona picker, so signing in is tapping a name – no password, and no network (ADR 021).
The mock serves a short seeded handbook. CAMPFIRE_CMS=https://campfire.wsj27.se pnpm start:local reads a deployed CMS's handbook instead, so a persona can show the real one.
Dev
Dev exists for the one thing the mock cannot do: the real sign-in flow. The back-end services are built from their dev branches – the ones the deployed dev site runs – on every start, beside a container running the same Vite dev server over the repository, so hot reload still works through the front door. The first start is slow while that container installs the workspace. A Postgres container beside them holds the cases, because the cases service is there only when a database is named, and they survive a restart of the stack.
Credentials never enter the repository. The Keycloak client and the Scoutnet keys go in a gitignored .env beside the compose file, which you write and nothing overwrites, and the first run on a machine without one prints what to write. The values are the ones the deployed services run with, so dev reads the real Scoutnet project. A write never reaches it, because the participants service keeps what is written – a patrol, for one – in an overlay of its own unless it is told to write through, and only prod tells it.
Dev can skip ScoutID. pnpm start:dev --user-id <memberNo> signs every sign-in straight in as that member, with the roles still taken from the list of participants, so the session behaves as that person's would – only the identity screens are skipped. Adding --roles grants the named roles to a member the list of participants does not know, which is how to test a role nobody at hand holds. The faked member lasts only for the run that asked for it.
On a cold start, a session made before the auth service has loaded the roles from the participants service would carry none, and read as a participant's. So in dev and prod the front door holds the web back, answering a page that reloads itself, until the auth service's health check says its roles are loaded, and the start script reports the stack ready only then. The roles arrive only once the participants service answers, and it answers only once its database and Scoutnet are read, so the one check waits for every service.
Prod
Prod is dev with the web served by the image pnpm build:image produced, so the production build, the image's own Caddy, and its single-page fallback all run before a deploy (ADR 026). start:prod never builds the image, because a stale image would run and mislead – a missing one is an error telling you to build it. It refuses --user-id, because prod is there to prove the real flow.
The CMS runs in neither. Dev and prod read the handbook from the deployed dev environment's CMS, which publishes it openly, so both need the internet for the handbook and show the content that is on dev. Its editor cannot be reached from either, because the CMS signs its editors in through the deployed auth service.
The image is linux/amd64, the cluster's platform, so an Apple-silicon machine runs it under emulation. Prod runs the same back-end containers as dev, Postgres included, except that they are built from their main, as the deployed prod site's are. It proves the image rather than the deployment.
Running a shell against it
pnpm start:android and pnpm start:apple boot an emulator or a simulator, build the shell, and launch it against http://localhost:8000. They take no environment – whichever stack is running is the environment – and refuse to start when nothing answers there. The Android emulator reaches the host's port 8000 through adb reverse, so localhost means the same machine on both sides and sign-in keeps its one host name.
The shells' dev, staging, and prod builds – pnpm build:android:dev and its siblings – bake in the deployed sites' origin instead, for a build meant to leave the machine.
The deployed sites
The web image runs on Scouterna's Kubernetes cluster in Azure, behind the same ingress as the back-end services – dev at campfire.wsj27.scouterna.net, staging at staging.campfire.wsj27.se, and prod at campfire.wsj27.se. The ingress is the deployed form of the local front door, routing the same prefixes the same way (ADR 027). Dev runs the dev branch, staging every release, and prod a promoted release, each decided by moving a tag (Release).
Staging has no back-end of its own. Its ingress routes to prod's services and signs in through ScoutID's production realm, so a release is tried against the real data and the sign-in it meets once promoted.