CI / go (Media) (push) Successful in 11m59s
CI / go (Server) (push) Failing after 18m26s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m35s
CI / desktop (ubuntu-latest) (push) Successful in 1h10m6s
CI / mobile (push) Failing after 3m43s
CI / docker (push) Successful in 1h2m44s
Docs / build (push) Successful in 11m58s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
ffmpeg parses untrusted uploads, so it moves out of the server image into a container of its own (ADR-15): - Media/: docwell-media, a small Go wrapper around ffmpeg. POST /v1/split takes a recording and returns the 16 kHz mono MP3 pieces as multipart/mixed. ffmpeg may only open local files and common audio/video demuxers (no playlists); optional shared token, a job limit, a timeout and a 1 GB cap. - Server: DOCWELL_MEDIA_URL and DOCWELL_MEDIA_TOKEN send recordings over 25 MB to the service. When it is blank or unreachable, the server uses a local ffmpeg if it has one, else cuts MP3 and WAV in Go. The server image no longer installs ffmpeg; the all-in-one image keeps it to stay one container. - Compose: a media service in every stack, read-only, no capabilities, on an internal network only docwell-server joins. - CI tests the new module and checks that only the server reaches media; the release workflow publishes docwell-media. - Docs, ADR-15 and the .env examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
115 lines
6.8 KiB
Markdown
115 lines
6.8 KiB
Markdown
# Docwell: separate services
|
|
|
|
docwell-db (PocketBase), docwell-server and docwell-web, each in its own container, plus docwell-media: ffmpeg,
|
|
which cuts recordings over 25 MB for transcription, on an internal network only docwell-server reaches. Remove the
|
|
`media` service and set `DOCWELL_MEDIA_URL=` (blank) to run without it; the server then cuts only MP3 and WAV.
|
|
For everything in one container, see [`../Docker-AIO`](../Docker-AIO/README.md).
|
|
|
|
| Compose file | Env template | Uploaded files live in | Use it for |
|
|
|---|---|---|---|
|
|
| `docker-compose.yml` | `.env.example` | the `pb_data` volume | development: builds this checkout (`--build`), Mailpit with `--profile dev` |
|
|
| `docker-compose.prod.yml` | `.env.prod.example` | the `pb_data` volume | production, released images |
|
|
| `docker-compose.prod.s3.yml` | `.env.prod.s3.example` | an S3 bucket that already exists elsewhere | production with AWS S3, MinIO, an existing SeaweedFS... |
|
|
| `docker-compose.prod.seaweedfs.yml` | `.env.prod.seaweedfs.example` | SeaweedFS in this stack, one container | production, self-hosted object store |
|
|
| `docker-compose.prod.seaweedfs.split.yml` | `.env.prod.seaweedfs.split.example` | SeaweedFS in this stack, one container per role + admin UI | the same, with the SeaweedFS admin UI and per-role control |
|
|
|
|
Every production file is self-contained: pick one, copy its template to `.env`, and pass the file with `-f`.
|
|
|
|
```bash
|
|
cp .env.prod.example .env # then edit: passwords, URLs, ports
|
|
docker compose -f docker-compose.prod.yml pull
|
|
docker compose -f docker-compose.prod.yml up -d
|
|
```
|
|
|
|
The web app is on `WEB_PORT` (3000) and the API, the `/collab` websocket and the admin panel (`/admin/`) on
|
|
`SERVER_PORT` (8080). Both are public, because the browser calls the API directly. Set `DOCWELL_WEB_URL`,
|
|
`DOCWELL_PUBLIC_URL` and `DOCWELL_COLLAB_URL` to the addresses browsers use. **The first account that signs
|
|
up becomes the instance admin.**
|
|
|
|
## The PocketBase image
|
|
|
|
docwell-db runs [`tajniak81/pocketbase-docker-root`](https://hub.docker.com/r/tajniak81/pocketbase-docker-root)
|
|
(source: [freefall-dev/PocketBase-docker](https://github.com/freefall-dev/PocketBase-docker), root variant) as it is,
|
|
with no Docwell files in it. That image downloads a pinned PocketBase release and checks it against the published
|
|
checksums. On every start its entrypoint creates the superuser from `PB_ADMIN_EMAIL` and `PB_ADMIN_PASSWORD` if it
|
|
does not exist yet, then starts `pocketbase serve` on port 8070.
|
|
|
|
docwell-server does the rest when it starts: it signs in as that superuser, brings PocketBase's collections up to
|
|
Docwell's schema (creating what is missing, keeping existing data), and writes the settings that come from the
|
|
environment (`DOCWELL_APP_NAME`, `DOCWELL_WEB_URL`, `DOCWELL_MAIL_FROM`, `DOCWELL_SMTP_*`, `DOCWELL_S3_*`). Upgrading
|
|
Docwell is therefore just a newer docwell-server; docwell-db changes only when you move to a newer PocketBase.
|
|
|
|
- Data lives in `/pb/pb_data` in the container.
|
|
- The PocketBase version is the image tag. Override it with `DB_IMAGE` in `.env`; any PocketBase image that creates
|
|
the superuser from `PB_ADMIN_*` and serves on port 8070 works.
|
|
- The base image is published for **linux/amd64 only**.
|
|
- `PB_ENCRYPTION_KEY` (exactly 32 characters, `openssl rand -hex 16`) turns on PocketBase's settings
|
|
encryption, which keeps the stored SMTP password and S3 secret encrypted. Set it before the first start and keep
|
|
a copy.
|
|
|
|
### Changing the PocketBase password
|
|
|
|
The entrypoint only *creates* the superuser. Once it exists, a new `PB_ADMIN_PASSWORD` in `.env` is not written to
|
|
the database, and docwell-server, which signs in with the value from `.env`, can no longer connect. Change it in the
|
|
database first, then in `.env`:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.prod.yml exec db \
|
|
/pb/pocketbase superuser upsert admin@example.com 'the-new-password' --dir /pb/pb_data
|
|
# now set PB_ADMIN_PASSWORD to the same value in .env, then:
|
|
docker compose -f docker-compose.prod.yml up -d
|
|
```
|
|
|
|
(With `PB_ENCRYPTION_KEY` set, add `--encryptionEnv=PB_ENCRYPTION_KEY` to that command.)
|
|
|
|
## File storage
|
|
|
|
By default uploaded files sit in `pb_data/storage`, next to the database. The S3 and SeaweedFS files move them into a
|
|
bucket instead; the database and PocketBase's own backups stay in `pb_data` either way. Clients never see the bucket:
|
|
every file goes through docwell-server.
|
|
|
|
The storage settings come from the `DOCWELL_S3_*` variables, which docwell-server writes into PocketBase on every
|
|
start. While `DOCWELL_S3_ENABLED` is set they win over the admin panel's **Storage** screen; with the plain
|
|
`docker-compose.prod.yml` (no `DOCWELL_S3_*`) the admin panel is in charge. "Test the saved bucket" in that screen
|
|
checks the connection either way.
|
|
|
|
- **External S3** (`prod.s3`): the endpoint and the bucket must already exist. For a gateway on the Docker host itself,
|
|
use `http://host.docker.internal:8333`; the file maps that name. Set `DOCWELL_S3_FORCE_PATH_STYLE=false` for AWS S3.
|
|
- **SeaweedFS** (`prod.seaweedfs`): `weed server -s3` in one container. The S3 credentials from `.env` are the
|
|
gateway's only identity; a one-shot `seaweedfs-init` container creates the bucket.
|
|
- **SeaweedFS split** (`prod.seaweedfs.split`): master, volume, filer and S3 gateway in separate containers plus the
|
|
SeaweedFS admin UI on `127.0.0.1:${SEAWEED_ADMIN_PORT}` (23646), which needs `SEAWEED_ADMIN_PASSWORD`.
|
|
`seaweedfs-init` writes PocketBase's identity into the filer's IAM store (the one the admin UI edits) on every start
|
|
and refuses to let the gateway start without it. Both SeaweedFS files lay out `SEAWEED_DATA` the same way, so you
|
|
can switch between them without moving data.
|
|
|
|
Back up `SEAWEED_DATA` together with `PB_DATA`: once S3 is on, the attachments live there.
|
|
|
|
### Switching an existing install to S3
|
|
|
|
PocketBase does **not** copy files that were uploaded before the switch; they stop loading until they are in the
|
|
bucket. Copy them while Docwell is stopped:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.prod.yml down
|
|
# Copy everything under pb_data/storage/ into the bucket root, keeping the paths,
|
|
# e.g. with the AWS CLI (or `mc mirror`, `rclone copy`):
|
|
docker run --rm -v docwell_pb_data:/pb_data:ro --network docwell_default \
|
|
-e AWS_ACCESS_KEY_ID=... -e AWS_SECRET_ACCESS_KEY=... \
|
|
amazon/aws-cli s3 sync /pb_data/storage s3://docwell/ --endpoint-url http://seaweedfs:8333
|
|
docker compose -f docker-compose.prod.seaweedfs.yml up -d
|
|
```
|
|
|
|
For the in-stack SeaweedFS, start `seaweedfs` and `seaweedfs-init` first
|
|
(`docker compose -f docker-compose.prod.seaweedfs.yml up -d seaweedfs-init`), so there is a bucket to copy into.
|
|
|
|
## Upgrading
|
|
|
|
```bash
|
|
docker compose -f docker-compose.prod.yml pull
|
|
docker compose -f docker-compose.prod.yml up -d
|
|
```
|
|
|
|
docwell-server updates PocketBase's collections when it starts. Pin `DOCWELL_VERSION` in production, and take a backup first
|
|
(admin panel → Backups, or a copy of the `pb_data` volume).
|