From d62799f263646268829f0799a3d0c5dd457629cc Mon Sep 17 00:00:00 2001 From: agent Date: Tue, 3 Nov 2026 09:10:16 +0000 Subject: [PATCH] PocketBase: switch image to elestio/pocketbase v0.23.12 spectado/pocketbase has been removed from Docker Hub. elestio publishes the same PocketBase version (0.23.12), so schema, migrations and hooks are unchanged. The image differs in packaging: - listens on 8090 instead of 80 (Caddyfile, POCKETBASE_INTERNAL_URL) - runs as non-root user `pocketbase` (uid 100), so pb_data written by the old root-run image needs a one-off chown; README documents it - pinned by digest as well as tag Tested: copy of an existing pb_data volume, README chown command via podman-compose, then the full stack (public page renders, admin and db routes via Caddy, shop hooks respond). A fresh volume also works. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HA82gX7xH4zwYTr5vE7mf8 --- AGENTS.md | 6 +++--- Caddyfile | 2 +- README.md | 15 ++++++++++++++- docker-compose.yml | 13 +++++++++---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1a91d05..fa3796a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ ## Stack - **SvelteKit 2** (SSR, Svelte 5 runes mode) — all `.svelte` files use `$state`, `$derived`, `$props()` etc. -- **PocketBase** — server pinned to **0.23.12** (`docker-compose.yml`), REST API via the `pocketbase` SDK (v0.26). Auth, DB, and image storage. Bump the server version deliberately (changelog, backup, test migrations). +- **PocketBase** — server pinned to **0.23.12** (`docker-compose.yml`, image `elestio/pocketbase`, digest-pinned; runs as non-root uid 100 on port 8090), REST API via the `pocketbase` SDK (v0.26). Auth, DB, and image storage. Bump the server version deliberately (changelog, backup, test migrations). - **Tailwind CSS v4** + **DaisyUI 5** — utility-first CSS with DaisyUI components for admin; custom theme for the public site. - **Docker Compose** — four services: `app-admin`, `app-public`, `pocketbase`, and `caddy` (reverse proxy). @@ -82,7 +82,7 @@ Caddyfile # Subdomain-based routing Caddy routes by `Host` header — no path stripping: - `admin.{$DOMAIN}:8080` → `app-admin:3001` (admin app) -- `db.{$DOMAIN}:8080` → `pocketbase:80` (redirects `/` to `/_/`) +- `db.{$DOMAIN}:8080` → `pocketbase:8090` (redirects `/` to `/_/`) - `www.{$DOMAIN}:8080`, `*.{$DOMAIN}:8080` → `app-public:3000` (public app) For local dev, `DOMAIN` defaults to `localhost`, so Caddy serves `admin.localhost:8080`, `db.localhost:8080`, `www.localhost:8080`. Caddy's `.localhost` handling works without DNS or hosts-file changes. @@ -193,7 +193,7 @@ cd app-public && npm run build - `DOMAIN` — base domain for subdomain routing. Defaults to `localhost` for local dev. Set in `docker-compose.yml` or `.env`. - `URL_SCHEME` (default `http`), `URL_PORT` (default `:8080`; set it empty for no port) — build every browser-facing URL below as `://.`. They must match the address bar exactly: a mismatched `ORIGIN` makes SvelteKit reject form POSTs (admin login) with "Cross-site POST form submissions are forbidden". Behind a TLS reverse proxy: `URL_SCHEME=https`, `URL_PORT=`. (podman-compose 1.5 can't do nested `${A:-${B}}` defaults, hence two flat variables.) - `PUBLIC_POCKETBASE_URL` — public-facing PocketBase URL (`://db.${DOMAIN}`). Set in `docker-compose.yml`. -- `POCKETBASE_INTERNAL_URL` — internal Docker network URL (`http://pocketbase:80`). Set in `docker-compose.yml`. +- `POCKETBASE_INTERNAL_URL` — internal Docker network URL (`http://pocketbase:8090`). Set in `docker-compose.yml`. - `ORIGIN` — SvelteKit origin for SSR. Differs per app: `://admin.${DOMAIN}` (admin), `://www.${DOMAIN}` (public). - `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`://www.${DOMAIN}`). - `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `EMAIL_FROM`, `EMAIL_FROM_NAME` — Brevo SMTP relay for booking emails (both apps). Empty `SMTP_HOST` = log emails instead of sending. diff --git a/Caddyfile b/Caddyfile index 5a4f529..9959c35 100644 --- a/Caddyfile +++ b/Caddyfile @@ -18,7 +18,7 @@ {$CADDY_SCHEME}://db.{$DOMAIN}:8080 { # PocketBase admin UI lives at /_/ — redirect bare root there. redir / /_/{path} - reverse_proxy pocketbase:80 + reverse_proxy pocketbase:8090 } {$CADDY_SCHEME}://www.{$DOMAIN}:8080, {$CADDY_SCHEME}://*.{$DOMAIN}:8080 { diff --git a/README.md b/README.md index 48606f9..e980d96 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Subsequent builds reuse the npm cache declared in each app's `Dockerfile`. The app containers use two PocketBase URLs: -- `POCKETBASE_INTERNAL_URL=http://pocketbase:80` for server-side SvelteKit calls from the app containers when using the included `spectado/pocketbase` image. +- `POCKETBASE_INTERNAL_URL=http://pocketbase:8090` for server-side SvelteKit calls from the app containers (the `elestio/pocketbase` image listens on 8090). - `PUBLIC_POCKETBASE_URL=http://db.${DOMAIN}:8080` for browser-side admin uploads and public file URLs. Points to the Caddy reverse proxy so browsers reach PocketBase via the `db` subdomain. ## PocketBase setup @@ -88,6 +88,19 @@ The app containers use two PocketBase URLs: If the `globals` records do not exist, the app falls back to safe defaults and the admin globals page will create them. +### Switching PocketBase image (existing installs) + +The PocketBase image changed from `spectado/pocketbase:0.23.12` (removed from Docker Hub) to `elestio/pocketbase:v0.23.12`. It is the same PocketBase version, so the schema, migrations and hooks are unchanged, but the new image runs as a non-root `pocketbase` user (uid 100) and listens on port 8090. Files the old image wrote are owned by root, and PocketBase refuses to start on them (`attempt to write a readonly database`). Fix the ownership once, before the first start on the new image: + +```sh +docker compose stop pocketbase +# back up first: the volume is _pocketbase (see `docker volume ls`) +docker compose run --rm --no-deps --user root --entrypoint chown pocketbase -R pocketbase:pocketbase /pb_data +docker compose up -d +``` + +Fresh installs need nothing: a new volume is created with the right owner. + ### Migrations `pocketbase/pb_migrations/` is mounted into the PocketBase container, which applies any new migration once when it starts (`docker compose up` / restart). The first one (`1791244800_lock_rules_dates_unique.js`) closes public sign-up on the `users` collection, makes order/basket writes superuser-only, adds `created`/`updated` dates and unique slug/key indexes. On an existing install, check the PocketBase log after restarting — if duplicate page slugs or global keys exist, the unique index is skipped with a log line. `1791331200_lock_order_lines.js` makes `order_lines` writes superuser-only (they were public). diff --git a/docker-compose.yml b/docker-compose.yml index 881482d..6c336ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,12 +3,17 @@ services: # Pinned: schema (pb_schema.json) and migrations target this version's # format/JS API. Upgrade deliberately — read the PocketBase changelog, # back up pb_data, then bump the tag and test migrations locally. - image: docker.io/spectado/pocketbase:0.23.12 + # Digest-pinned too, so a re-pushed tag can't change what runs. + # This image runs as a non-root `pocketbase` user (uid 100) on port 8090 + # and finds /pb_migrations and /pb_hooks next to /pb_data by default. + # Data written by the old root-run image (spectado/pocketbase, now gone) + # must be chown'ed once — see the README's "Switching PocketBase image". + image: docker.io/elestio/pocketbase:v0.23.12@sha256:e8c375d4fd50c4ee2f2922361392ba7c6b16c4d5df39bfc7cf2372af2bc3305e container_name: massage-pocketbase restart: unless-stopped # Internal only — accessed via the caddy reverse proxy expose: - - "80" + - "8090" volumes: - pocketbase:/pb_data # Versioned schema changes; PocketBase applies pending ones on start. @@ -33,7 +38,7 @@ services: - pocketbase environment: PORT: 3001 - POCKETBASE_INTERNAL_URL: http://pocketbase:80 + POCKETBASE_INTERNAL_URL: http://pocketbase:8090 # Browser-facing URLs. They must match the address bar exactly, or # SvelteKit rejects logins/forms ("Cross-site POST form submissions are # forbidden"). Behind a TLS proxy: URL_SCHEME=https and URL_PORT= (empty). @@ -64,7 +69,7 @@ services: - pocketbase environment: PORT: 3000 - POCKETBASE_INTERNAL_URL: http://pocketbase:80 + POCKETBASE_INTERNAL_URL: http://pocketbase:8090 PUBLIC_POCKETBASE_URL: ${URL_SCHEME:-http}://db.${DOMAIN:-localhost}${URL_PORT-:8080} ORIGIN: ${URL_SCHEME:-http}://www.${DOMAIN:-localhost}${URL_PORT-:8080} # No PocketBase or Stripe secrets here: shop writes happen in PocketBase