Files
PilotVault/Docker-AIO/README.md
T
tajniak81andClaude Opus 5.5 3962530841 Docker-AIO: S3 and SeaweedFS variants, matching DriverVault
Docker-AIO gets the same deployment shapes as DriverVault: plain,
SeaweedFS, SeaweedFS split into its roles, and an external S3 endpoint,
each as a build-from-source and a prod compose file with an .env example
of the same name, plus a README. The from-source SeaweedFS files run the
store as side containers; the prod ones build Dockerfile.seaweedfs or
Dockerfile.seaweedfs.split, which bake `weed server -s3` or its five
separate roles into the image under supervisord.

The image is rebuilt around PilotVault's real layout. The old Dockerfile
copied "Web App/ui" and "Web App/main.go", which no longer exist, and
pinned PocketBase 0.22.21, which cannot run the migrations; it now builds
"Web App/web" + "Web App/server" and pins 0.39.11. Unlike DriverVault's
nginx front, the Go BFF keeps serving the UI on 8090. Every process runs
as an unprivileged user, plugins.json gets an /app/data volume, the
container is healthy only when every process answers, and no default
superuser credentials are baked in.

Verified on Docker from an empty database: plain, both SeaweedFS
from-source and both baked prod variants come up healthy, document
uploads land in the bucket and download back. The external-S3 files are
checked with `docker compose config` only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:08:53 +01:00

212 lines
10 KiB
Markdown

# PilotVault — Docker AIO (all-in-one image)
**PocketBase + API Server + Web App in a single container**, supervised by
`supervisord`. One image, one container, no compose network — the simplest way
to stand PilotVault up on a single host.
Prefer the three-container stack in [`../Docker`](../Docker) when you want to
scale, upgrade or restart the pieces independently.
```
:8090 Web App BFF ──/api/*──► API Server on 127.0.0.1:8080 ─► PocketBase on :8070
```
| File | Use |
|---|---|
| `Dockerfile` | the all-in-one image (build context must be the **repo root**) |
| `Dockerfile.seaweedfs` | the same, with SeaweedFS (`weed server -s3`) baked in — see below |
| `Dockerfile.seaweedfs.split` | the same, with SeaweedFS split into its roles baked in — see below |
| `docker-compose.yml` | **builds from source** — for development and local testing |
| `docker-compose.prod.yml` | **pulls the prebuilt image** from the registry |
| `.env.example` / `.env.prod.example` | copy to `.env` for the matching compose file |
| `docker-compose[.prod].{s3,seaweedfs,seaweedfs.split}.yml` | the same with file storage in S3 — see [File storage](#file-storage-seaweedfs--s3) |
## Run it
```bash
cd Docker-AIO
cp .env.example .env # then edit — POCKETBASE_ADMIN_* have no safe defaults
docker compose up -d --build
```
Production, from the registry:
```bash
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/_/`.
## Building by hand
The build context **must be the repo root** so the Dockerfile can reach both
`API Server/` and `Web App/` (the root `.dockerignore` keeps the Fly/Phone apps
out of it):
```bash
docker build -f "Docker-AIO/Dockerfile" -t pilotvault-aio .
```
The image builds both Vue frontends (the API Server panel and the Web App UI)
and both Go binaries from source. Build arg `PB_VERSION` is pinned in the
Dockerfile (v0.39.11 — it must be v0.23 or newer for the bundled migrations);
override it to build a different PocketBase, or set it to an empty string to
resolve the latest release at build time.
## First boot
Identical to the multi-container stack, and idempotent:
1. PocketBase upserts its superuser from `POCKETBASE_ADMIN_EMAIL` /
`POCKETBASE_ADMIN_PASSWORD` — the API Server then authenticates with the same
credentials.
2. PocketBase runs the bundled JS migrations, which create/reconcile every
collection and seed the baseline org and accounts, including the
`superadmin@pilotvault.local` app login.
3. The API Server waits for PocketBase to report healthy, then starts; the Web
App waits for the API Server.
The image no longer bakes in default superuser credentials: the compose files
refuse to start without `POCKETBASE_ADMIN_*` in `.env`.
## Volumes
| Volume | Holds |
|---|---|
| `/pb/pb_data` (`PB_DATA`) | the PocketBase SQLite database, its backups and — unless S3 is on — the uploaded document blobs |
| `/app/data` (`API_DATA`) | the API Server's `plugins.json`: plugin enable-state and config |
Both default to Docker-managed named volumes; set `PB_DATA` / `API_DATA` to an
absolute host path in `.env` for a bind mount. Every process runs as the
unprivileged `app` user; the entrypoint stays root only long enough to take
ownership of a root-owned bind mount, then hands off to supervisord.
> One thing does **not** persist: the API Server panel's *Settings → PocketBase*
> screen applies immediately but only for the life of the container. Set the
> corresponding environment variables to change things permanently.
## File storage (SeaweedFS / S3)
Uploaded files — the document store's scans of pilot certificates, aircraft
registrations, insurance and authorisations — live inside `pb_data` by default,
next to the database. The further compose files put them in an S3 bucket
instead, so the blobs and the database can be sized, backed up and moved
independently. Nothing else changes: a document has always been downloaded
through the API Server (`GET /api/documents/{id}/file`), never from a storage
URL, so the Web App and the Fly/Phone apps cannot tell the difference.
Each shape is one self-contained compose file — nothing to layer, nothing to
remember — with an `.env` example of the same name:
| Shape | From the registry | From source |
|---|---|---|
| **Local storage** — the default, unchanged | `docker-compose.prod.yml` | `docker-compose.yml` |
| **SeaweedFS** | `docker-compose.prod.seaweedfs.yml` (builds `Dockerfile.seaweedfs`) | `docker-compose.seaweedfs.yml` |
| **SeaweedFS, split into its roles** | `docker-compose.prod.seaweedfs.split.yml` (builds `Dockerfile.seaweedfs.split`) | `docker-compose.seaweedfs.split.yml` |
| **An S3 endpoint elsewhere** | `docker-compose.prod.s3.yml` | `docker-compose.s3.yml` |
So `docker-compose.prod.seaweedfs.yml` is configured from
`.env.prod.seaweedfs.example`, `docker-compose.s3.yml` from `.env.s3.example`,
and so on:
```sh
cp .env.prod.seaweedfs.example .env # then edit it — PB_S3_* have no defaults
docker compose -f docker-compose.prod.seaweedfs.yml build
docker compose -f docker-compose.prod.seaweedfs.yml up -d
```
Set `PB_S3_ACCESS_KEY` and `PB_S3_SECRET` first — every storage file refuses to
start without them.
- The **from-source SeaweedFS files** run the object store **beside** the
all-in-one: a `seaweedfs` container (master, volume, filer and S3 in one
process, on its own `seaweed_data` volume) plus a one-shot `seaweedfs-init`
that creates the bucket, because PocketBase never issues a `CreateBucket` of
its own.
- The **prod SeaweedFS files** go the other way and **build it into the image**:
`Dockerfile.seaweedfs` runs `weed server -s3` as one more supervisord program
(the `weed` binary is copied from the official image, pinned by the
`SEAWEED_VERSION` build arg) on a `/seaweed/data` volume of its own, with
PocketBase's program creating the bucket before it serves. One container, the
cost being that a new SeaweedFS is a rebuild rather than a tag change. Inside,
the volume server sits on **8081** since 8080 is the API Server, every
SeaweedFS role binds loopback, and nothing of SeaweedFS is published. The
build needs the repo checkout, so either build on the deploy host or
`docker compose push` the image to `AIO_IMAGE` and `pull` it there.
- The **external-S3 files** add no containers at all: set `PB_S3_ENDPOINT`, and
create the bucket yourself.
### Split SeaweedFS
`weed server -s3` runs master, volume, filer and gateway as four goroutines in
one process. `docker-compose.seaweedfs.split.yml` runs them as four containers
beside the all-in-one, plus a fifth: the SeaweedFS **admin UI** on port 23646,
where the cluster can be inspected and — under *Object Store → Users* — further
S3 identities minted and revoked.
The prod twin builds it in: `docker-compose.prod.seaweedfs.split.yml` **builds
`Dockerfile.seaweedfs.split`**, which bakes all five roles into the all-in-one
image as five more supervisord programs, with the bucket-and-identity seed run
inside the gateway's program instead of a `seaweedfs-init` container. What
survives of "split" in there is per-role restart, per-role metrics ports and the
admin UI; what does not is spreading the roles over hosts. Only the admin UI is
published, on loopback by default.
Identities work differently there, and it matters. SeaweedFS reads credentials
from, in descending priority: an `-s3.config` file, the filer's IAM store, then
`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` — and a higher source *replaces* a
lower one rather than adding to it. The single-gateway files use the env vars,
which is why nothing else may write identities there: the first user added in a
panel would displace PocketBase's key. So the split files seed PocketBase's
identity (named `pilotvault`) into the filer's store instead — the same store the
admin UI writes — and the gateway runs with no config file at all. Rotating
`PB_S3_SECRET` in `.env` and restarting updates that identity in place.
Set `SEAWEED_ADMIN_PASSWORD`: `weed admin` serves the panel with no
authentication when it is empty, and a panel that can mint bucket credentials is
the bucket (the baked-in image refuses to start the panel at all without one).
A remote host needs `SEAWEED_ADMIN_BIND=0.0.0.0` behind a reverse proxy.
Switching between any of the SeaweedFS files needs no migration: master, volume
and filer share one data mount (`/data` in the side containers, `/seaweed/data`
in the baked-in image), which is exactly the layout `weed server -dir` writes.
### How the switch happens
On every boot the API Server reads `PB_S3_*` and writes PocketBase's *Files
storage* settings from them (only when they differ), then asks PocketBase to
prove it can reach the bucket:
```
[api] storage: ✓ file storage → S3 (pilotvault at http://127.0.0.1:8333)
[api] storage: ✓ S3 storage reachable
```
A boot that finds the settings already correct logs
`• file storage already on S3` and writes nothing.
- **Existing files are not migrated.** PocketBase copies nothing when the setting
flips, so documents uploaded before the switch stop resolving. Copy
`pb_data/storage/<collectionId>/<recordId>/<file>` into the bucket root, keeping
that layout, *before* enabling it — or start from a stack with no documents.
- **Going back to the plain compose file is not an off switch.** It leaves
PocketBase pointed at the bucket, deliberately. Move the files back and turn it
off in PocketBase's own admin UI. A rotation of `PB_S3_SECRET` alone is
invisible to the API Server (PocketBase masks the stored secret on read), so
change another `PB_S3_*` value alongside it, or set it in the admin UI.
## Caveats
- A crash of `supervisord` takes every process down together — that is the trade
for the simplicity.
- Logs from all processes are interleaved on the container's stdout/stderr
(`docker logs pilotvault-aio`).
- The container reports health once every process answers its probe (the Web
App's is its index page), so a wedged component shows up in `docker ps` rather
than looking up.
- Nothing in the image terminates TLS. Put your own reverse proxy in front of
the Web App port and set `CORS_ALLOW_ORIGINS` to its public origin.