01a8fecfixed the advice that led operators into this, but advice is not a guard: a stack still running PB_BOOTSTRAP=false gets no app_settings collection on upgrade, and the plugin panel sits at 503 while the retry loop reads a collection that does not exist. The fix is not to soften the reading. A missing collection stays "not ready" rather than "no plugins configured", because the alternative lets the first save write a fresh document over settings the server merely failed to find - the failure this whole line of work exists to prevent. Instead the server now fixes the cause: on a missing collection it creates that collection and reads again. Three pieces: bootstrap.EnsureCollection creates one named collection from the desired schema if absent, and nothing else. Deliberately narrower than Run - no field reconcile elsewhere, no super-admin - so it is safe to call on a deployment that turned the full bootstrap off. It creates the collection the server cannot start without, not the schema the operator declined. The store tells a missing collection apart from an outage. A 404 from a list means the collection itself is gone: an existing but empty one answers 200 with no items. That is tagged errNoCollection, which wraps errNotReady so every write is still refused, and IsMissingCollection narrows it. The distinction matters because the remedies are opposites - creating collections against a flaky database is exactly the wrong reflex, and a test pins that an outage does not trigger it. loadPlugins acts on the tag once, then re-reads. Failing to create is reported as the original read error rather than the repair's, so the log names the real problem. Six tests: the tag and its negative in internal/plugins, and three in internal/api against a fake PocketBase covering the collection being created exactly once, an existing collection not being recreated, and an outage creating nothing. Docs from01a8fecare corrected in the same pass - they said the panel would answer 503 forever, which is no longer true. They now say what still depends on the bootstrap (every other collection and field) and what does not (app_settings alone). go build, go vet and go test ./... pass; compose files still parse. Not verified: no Docker CLI here, so the repair has not been exercised against a real PocketBase, only the fake. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
5.1 KiB
DriverVault — Docker (multi-container stack)
Three containers — PocketBase, API Server, Web App — on one compose
network. This is the deployment to use unless you specifically want everything
in a single image; for that see ../Docker-AIO.
Browser ─► Web App BFF (:8090) ──/api/*──► API Server (:8080) ─► PocketBase (:8070)
Only the Web App port is meant to be public. The API Server and the PocketBase
admin UI are published for convenience and, in the prod file, bound to
127.0.0.1 by default.
| File | Use |
|---|---|
docker-compose.yml |
builds from source in this repo — for development and local testing |
docker-compose.prod.yml |
pulls prebuilt images from the registry — for deployment |
.env.example / .env.prod.example |
copy to .env for the matching compose file |
pocketbase/ |
the PocketBase image (official release binary on alpine) |
Run it
cd Docker
cp .env.example .env # then edit — PB_ADMIN_* have no safe defaults
docker compose up -d --build
Production, from the registry:
cp .env.prod.example .env # then edit
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d
Then: web app on http://host:8090/, the API Server's superadmin panel on
http://host:8080/, PocketBase admin on http://host:8070/_/.
First boot
Both steps are idempotent, so restarts and upgrades are safe:
- PocketBase upserts its superuser from
PB_ADMIN_EMAIL/PB_ADMIN_PASSWORD. This is the only way to create the first superuser — the REST API cannot bootstrap it. The API Server then authenticates with the same credentials. - The API Server creates any missing collections and reconciles existing
ones, then creates the first app
superadminfromDRIVERVAULT_SUPERADMIN_EMAIL/_PASSWORDif no such user exists.
Leave
PB_BOOTSTRAPattrue, including across upgrades. A release can add collections or fields the server needs, and a stack that skipped the bootstrap never gets them. The API Server self-heals exactly one thing —app_settings, the collection holding the plugin settings, which it creates on demand because it cannot serve the plugin panel without it. Every other schema change still depends on this flag, so turn it off only for a database you know already matches the release you are running.
No manual setup-pocketbase.mjs step is needed here — the server runs the same
schema reconcile itself.
Volumes
| Volume | Holds |
|---|---|
pb_data |
the PocketBase SQLite database and uploaded files |
api_data |
the .env the API Server panel rewrites when a superadmin retargets the PocketBase connection (plugin settings live in pb_data, with everything else) |
Both default to Docker-managed named volumes. In the prod file, set PB_DATA /
API_DATA to absolute host paths for bind mounts instead.
The API Server serves as the unprivileged
appuser, so/datahas to be writable by it. Its entrypoint arranges that itself: it starts as root, takes ownership of/dataifappdoes not already hold it, then drops privileges. So a bind mount to a root-owned host path needs no manualchown, and neither does a named volume left over from an image that ran as root. The one case it cannot fix is a container forced to another user (user:in compose,docker run --user), where the entrypoint has no privileges tochownwith — prepare the host directory yourself there. PocketBase runs as root, soPB_DATAis unaffected either way.
Plugin enable-state and global config used to live in a plugins.json on this
volume, which made them the one piece of configuration a lost volume could erase
without anyone noticing. They are now in PocketBase, backed up with pb_data
like everything else. An existing plugins.json is imported automatically on the
first boot after the upgrade and renamed to plugins.json.migrated; keep the
volume mounted for that boot.
Charger control (OCPP)
Chargers in own/proxy mode dial in to /ocpp/{serial} on the API Server
port, authenticating with a per-charger control token in an OCPP Basic-auth
header. A plaintext ws:// would put that token on the wire in the clear, so
OCPP_REQUIRE_TLS defaults to true and non-TLS connections are rejected.
This stack serves plain HTTP, so to actually use charger control you need to
terminate TLS in a reverse proxy in front of it and set OCPP_PUBLIC_URL to the
public wss:// base (behind a proxy, deriving it from request headers is
unreliable). OCPP_REQUIRE_TLS=false is for trusted networks only. You will
also need API_BIND set so the proxy can reach the port.
Notes
docker-compose.ymlbuilds the API Server and Web App from../API Serverand../Web App, so run it from this directory with the repo checked out.- The Web App's Vue bundle is built with an empty
VITE_API_BASE, so the browser uses same-origin/apiand the BFF proxies it — no CORS in play. CORS_ALLOW_ORIGINStherefore only matters if a browser calls the API Server directly. Native mobile apps are not subject to CORS at all.