Compare commits

..

2 commits

Author SHA1 Message Date
5b92cae225 Merge pull request 'PocketBase: switch image to elestio/pocketbase v0.23.12' (#27) from session/change-pocketbase-image into main
Reviewed-on: #27
2026-11-03 10:25:42 +01:00
d62799f263 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gX7xH4zwYTr5vE7mf8
2026-11-03 09:10:16 +00:00
4 changed files with 27 additions and 9 deletions

View file

@ -3,7 +3,7 @@
## Stack ## Stack
- **SvelteKit 2** (SSR, Svelte 5 runes mode) — all `.svelte` files use `$state`, `$derived`, `$props()` etc. - **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. - **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). - **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: Caddy routes by `Host` header — no path stripping:
- `admin.{$DOMAIN}:8080` → `app-admin:3001` (admin app) - `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) - `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. 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`. - `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 `<scheme>://<sub>.<DOMAIN><port>`. 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.) - `URL_SCHEME` (default `http`), `URL_PORT` (default `:8080`; set it empty for no port) — build every browser-facing URL below as `<scheme>://<sub>.<DOMAIN><port>`. 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 (`<scheme>://db.${DOMAIN}<port>`). Set in `docker-compose.yml`. - `PUBLIC_POCKETBASE_URL` — public-facing PocketBase URL (`<scheme>://db.${DOMAIN}<port>`). 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: `<scheme>://admin.${DOMAIN}<port>` (admin), `<scheme>://www.${DOMAIN}<port>` (public). - `ORIGIN` — SvelteKit origin for SSR. Differs per app: `<scheme>://admin.${DOMAIN}<port>` (admin), `<scheme>://www.${DOMAIN}<port>` (public).
- `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`<scheme>://www.${DOMAIN}<port>`). - `PUBLIC_SITE_URL` — public site URL used by the admin app for cross-subdomain preview links (`<scheme>://www.${DOMAIN}<port>`).
- `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. - `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.

View file

@ -18,7 +18,7 @@
{$CADDY_SCHEME}://db.{$DOMAIN}:8080 { {$CADDY_SCHEME}://db.{$DOMAIN}:8080 {
# PocketBase admin UI lives at /_/ — redirect bare root there. # PocketBase admin UI lives at /_/ — redirect bare root there.
redir / /_/{path} redir / /_/{path}
reverse_proxy pocketbase:80 reverse_proxy pocketbase:8090
} }
{$CADDY_SCHEME}://www.{$DOMAIN}:8080, {$CADDY_SCHEME}://*.{$DOMAIN}:8080 { {$CADDY_SCHEME}://www.{$DOMAIN}:8080, {$CADDY_SCHEME}://*.{$DOMAIN}:8080 {

View file

@ -73,7 +73,7 @@ Subsequent builds reuse the npm cache declared in each app's `Dockerfile`.
The app containers use two PocketBase URLs: 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. - `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 ## 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. 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 <project>_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 ### 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). `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).

View file

@ -3,12 +3,17 @@ services:
# Pinned: schema (pb_schema.json) and migrations target this version's # Pinned: schema (pb_schema.json) and migrations target this version's
# format/JS API. Upgrade deliberately — read the PocketBase changelog, # format/JS API. Upgrade deliberately — read the PocketBase changelog,
# back up pb_data, then bump the tag and test migrations locally. # 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 container_name: massage-pocketbase
restart: unless-stopped restart: unless-stopped
# Internal only — accessed via the caddy reverse proxy # Internal only — accessed via the caddy reverse proxy
expose: expose:
- "80" - "8090"
volumes: volumes:
- pocketbase:/pb_data - pocketbase:/pb_data
# Versioned schema changes; PocketBase applies pending ones on start. # Versioned schema changes; PocketBase applies pending ones on start.
@ -33,7 +38,7 @@ services:
- pocketbase - pocketbase
environment: environment:
PORT: 3001 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 # Browser-facing URLs. They must match the address bar exactly, or
# SvelteKit rejects logins/forms ("Cross-site POST form submissions are # SvelteKit rejects logins/forms ("Cross-site POST form submissions are
# forbidden"). Behind a TLS proxy: URL_SCHEME=https and URL_PORT= (empty). # forbidden"). Behind a TLS proxy: URL_SCHEME=https and URL_PORT= (empty).
@ -64,7 +69,7 @@ services:
- pocketbase - pocketbase
environment: environment:
PORT: 3000 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} PUBLIC_POCKETBASE_URL: ${URL_SCHEME:-http}://db.${DOMAIN:-localhost}${URL_PORT-:8080}
ORIGIN: ${URL_SCHEME:-http}://www.${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 # No PocketBase or Stripe secrets here: shop writes happen in PocketBase