Skip to content

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.

EnvironmentStart withThe web application/api/auth and /api/projectSign-in
localpnpm start:localVite, on the hostThe mock, on the hostA persona picker
devpnpm start:devVite, in a containerThe real back-end, in containersReal ScoutID, or a faked member
prodpnpm start:prodThe built imageThe real back-end, in containersReal 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.

Pathlocaldevprod
/api/authThe mockThe auth serviceThe auth service
/api/projectThe mockThe project APIThe project API
/__mock__The mock's ScoutID stand-in and control surface––
Everything elseVite on the hostVite in a containerThe 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.

Deployment diagram of the local environment. On a developer's machine, Caddy on port 8000 is the one origin, proxying /api/auth and /api/project to the mock back-end and every other path to the web app on Vite. The Apple shell in the iOS Simulator and the Android shell in the emulator load the application from Caddy.

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.

Deployment diagram of the deployed dev environment. In Azure, a Kubernetes cluster runs an ingress as the one origin over HTTPS, routing /api/auth to the auth service, /api/project to the participants service, /api/project/cases to the cases service, which keeps its cases in Postgres, and every other path to the web app. The auth service runs the OpenID round trip with ScoutID, and the participants service reads member data from and stores patrols in Scoutnet. The Apple and Android shells on a member's phone load the application from the ingress.

Deployment diagram of the deployed staging environment: its own ingress and web app in the Kubernetes cluster in Azure, routing /api/auth to prod's auth service, /api/project to prod's participants service, and /api/project/cases to prod's cases service, which keeps its cases in prod's Postgres. The auth service signs in through ScoutID's production realm, the participants service reads Scoutnet and stores patrols in it, and the shells on a member's phone load the application from the ingress.

Deployment diagram of the deployed prod environment, the same shape as dev: an ingress in the Kubernetes cluster in Azure routes /api/auth to the auth service, /api/project to the participants service, /api/project/cases to the cases service, which keeps its cases in Postgres, and every other path to the web app. The auth service signs in through ScoutID, the participants service reads Scoutnet and stores patrols in it, and the shells on a member's phone load the application from the ingress.