Files
Docwell/Docker
tajniak81andClaude Opus 5.5 b9be8be156
CI / go (Server) (push) Failing after 22m50s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m47s
CI / desktop (ubuntu-latest) (push) Successful in 2h56m50s
CI / mobile (push) Failing after 5m33s
CI / docker (push) Successful in 1h43m8s
Docs / build (push) Successful in 16m2s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Run docwell-db as a stock PocketBase and let the server set it up
docwell-db no longer needs a Docwell image: the stack runs
tajniak81/pocketbase-docker-root as it is, and docwell-server does what
the migrations and pb_hooks used to do inside PocketBase.

On start, docwell-server now:
- waits for PocketBase and imports Docwell's collections from an
  embedded snapshot (internal/pbschema). Existing collections and
  fields are matched by name, so their data is kept; the admin-managed
  users options (OAuth2 providers, magic link) are left untouched.
- writes the DOCWELL_APP_NAME, DOCWELL_WEB_URL, DOCWELL_MAIL_FROM,
  DOCWELL_SMTP_* and DOCWELL_S3_* settings into PocketBase, as the
  boot hook did.

It also replaces the hook's two routes: token checks use PocketBase's
auth-refresh (the organization name is read as the superuser), and
Docwell's own emails go out over SMTP from the server. PocketBase never
returns the SMTP password, so the server keeps a copy in the
superuser-only instance_settings collection; a password saved before
this change has to be entered once more in the admin panel.

Database/ keeps pb_migrations as the source of the schema;
export-schema.sh regenerates the snapshot from them. Database/Dockerfile
and pb_hooks are removed, the release no longer builds docwell-db, the
AIO image runs PocketBase without migrations or hooks, and the compose
files default DB_IMAGE to the stock image and pass the settings to the
server instead of the database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:09:38 +01:00
..

Docwell: separate services

docwell-db (PocketBase), docwell-server and docwell-web, each in its own container. For everything in one container, see ../Docker-AIO.

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.

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 (source: 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:

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:

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

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).