domaino/docker-compose.yml
agent 9264289813 PocketBase: close public sign-up, lock commerce writes, add dates/unique keys
Security:
- PocketBase's default `users` collection allows anonymous sign-up, and
  every CMS rule only checks "signed in" (the admin login also accepts
  `users`). Anyone could register via the public API and edit the site,
  read orders/customer details, or log into the admin. Sign-up is now
  superuser-only.
- orders.create, baskets.create/update and basket_lines.create/update/
  delete were open to anonymous requests, allowing forged "paid" orders in
  the admin and basket tampering. The public app performs all of these
  server-side with the admin client, so they are now superuser-only
  (basket add-item/add-slot verified still working).

Data:
- created/updated autodate fields on all app collections; orders are now
  listed newest-first by date (ids are random, '-id' was not chronological).
- Unique indexes on pages.slug and globals.key (skipped with a log line if
  existing data has duplicates, so PocketBase still starts).

Delivered as a JS migration in pocketbase/pb_migrations, mounted into the
container (the image already passes --migrationsDir=/pb_migrations), so it
applies once on the next start. pb_schema.json carries the same changes for
fresh installs, where the migration runs before the schema is imported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
2026-10-06 10:55:12 +00:00

97 lines
3.4 KiB
YAML

services:
pocketbase:
image: docker.io/spectado/pocketbase:latest
container_name: massage-pocketbase
restart: unless-stopped
# Internal only — accessed via the caddy reverse proxy
expose:
- "80"
volumes:
- pocketbase:/pb_data
# Versioned schema changes; PocketBase applies pending ones on start.
- ./pocketbase/pb_migrations:/pb_migrations:ro,Z
app-admin:
build:
context: .
dockerfile: app-admin/Dockerfile
container_name: massage-app-admin
restart: unless-stopped
depends_on:
- pocketbase
environment:
PORT: 3001
POCKETBASE_INTERNAL_URL: http://pocketbase:80
PUBLIC_POCKETBASE_URL: http://db.${DOMAIN:-localhost}:8080
ORIGIN: http://admin.${DOMAIN:-localhost}:8080
PUBLIC_SITE_URL: http://www.${DOMAIN:-localhost}:8080
BODY_SIZE_LIMIT: 52428800 # 50MB — import payload embeds all images as base64
# Commerce (reservation & payment system) — set these in a root-level .env
POCKETBASE_ADMIN_EMAIL: ${POCKETBASE_ADMIN_EMAIL:-}
POCKETBASE_ADMIN_PASSWORD: ${POCKETBASE_ADMIN_PASSWORD:-}
STRIPE_CURRENCY: ${STRIPE_CURRENCY:-eur}
# Booking emails (Brevo SMTP relay) — admin needs these for resend/test sends
SMTP_HOST: ${SMTP_HOST:-}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_USER: ${SMTP_USER:-}
SMTP_PASS: ${SMTP_PASS:-}
EMAIL_FROM: ${EMAIL_FROM:-}
EMAIL_FROM_NAME: ${EMAIL_FROM_NAME:-}
SITE_TIMEZONE: ${SITE_TIMEZONE:-Europe/Oslo}
# Internal only — served via the caddy reverse proxy
expose:
- "3001"
app-public:
build:
context: .
dockerfile: app-public/Dockerfile
container_name: massage-app-public
restart: unless-stopped
depends_on:
- pocketbase
environment:
PORT: 3000
POCKETBASE_INTERNAL_URL: http://pocketbase:80
PUBLIC_POCKETBASE_URL: http://db.${DOMAIN:-localhost}:8080
ORIGIN: http://www.${DOMAIN:-localhost}:8080
# Commerce (reservation & payment system) — set these in a root-level .env
POCKETBASE_ADMIN_EMAIL: ${POCKETBASE_ADMIN_EMAIL:-}
POCKETBASE_ADMIN_PASSWORD: ${POCKETBASE_ADMIN_PASSWORD:-}
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY:-}
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET:-}
PUBLIC_STRIPE_PUBLISHABLE_KEY: ${PUBLIC_STRIPE_PUBLISHABLE_KEY:-}
STRIPE_CURRENCY: ${STRIPE_CURRENCY:-eur}
# Booking emails (Brevo SMTP relay) — sent from the Stripe webhook
SMTP_HOST: ${SMTP_HOST:-}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_USER: ${SMTP_USER:-}
SMTP_PASS: ${SMTP_PASS:-}
EMAIL_FROM: ${EMAIL_FROM:-}
EMAIL_FROM_NAME: ${EMAIL_FROM_NAME:-}
SITE_TIMEZONE: ${SITE_TIMEZONE:-Europe/Oslo}
# Internal only — served via the caddy reverse proxy
expose:
- "3000"
caddy:
image: docker.io/library/caddy:2-alpine
container_name: massage-caddy
restart: unless-stopped
ports:
- "8080:8080"
environment:
DOMAIN: ${DOMAIN:-localhost}
# Scheme used in Caddyfile site addresses. "http" = plain HTTP on :8080
# (matches the ORIGIN vars below). Switch to "https" only if you also
# update ORIGIN/PUBLIC_* URLs and provide a cert issuer.
CADDY_SCHEME: ${CADDY_SCHEME:-http}
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro,Z
depends_on:
- app-admin
- app-public
- pocketbase
volumes:
pocketbase: