sightbox/docker-compose.yml

151 lines
7.9 KiB
YAML

# Root launch path for the sightbox deployment (Dokploy points here).
# Brings up frappe_docker's unmodified stack via `include:` (base compose.yaml
# + the mariadb/redis/noproxy overrides, merged exactly as multiple -f flags
# would merge them) and adds this client's one custom service, backend-billing,
# on the same default project network. frappe_docker/ itself is never edited
# or duplicated here — see frappe_docker/docs/02-setup/05-overrides.md for
# what each included override file does.
#
# noproxy is used (not compose.https.yaml/compose.traefik.yaml) because
# Dokploy provides its own reverse proxy/TLS layer in front of whatever port
# a compose service exposes; running frappe_docker's own Traefik here would
# double up proxies. Reassess if the deployment target changes.
include:
- path:
- frappe_docker/compose.yaml
- frappe_docker/overrides/compose.mariadb.yaml
- frappe_docker/overrides/compose.redis.yaml
- frappe_docker/overrides/compose.noproxy.yaml
services:
# frappe_docker/compose.yaml hardcodes platform: linux/amd64 on every
# Frappe-image service. That's correct for the real deployment target
# (an x86_64 Dokploy VPS) but forces QEMU emulation on an Apple Silicon
# dev machine, where pyarrow's native code segfaults under emulation.
# FRAPPE_IMAGE_PLATFORM lets a local arm64 dev machine override this to
# linux/arm64 (frappe/erpnext ships a native arm64 image) via its own
# .env, without changing the default for production.
configurator:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
backend:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
frontend:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
websocket:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
queue-short:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
queue-long:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
scheduler:
platform: ${FRAPPE_IMAGE_PLATFORM:-linux/amd64}
marketing:
# The public BettersightBox marketing/sales page — deliberately NOT a
# Frappe Web Page. Confirmed the hard way: stock Frappe/ERPNext has no
# mechanism to serve a fully custom, unwrapped HTML document at a route
# without a custom app — every Web Page unconditionally extends
# templates/web.html, so Frappe's own topbar/footer would wrap around
# this page's own from-scratch nav/hero and double up. A plain nginx
# service serving the file directly keeps it fully decoupled from
# Frappe's templating and safe across Frappe/ERPNext upgrades.
#
# This container fronts the product's own marketing domain, separate
# from any client's ERPNext site (which lives on its own domain/
# subdomain via the `frontend` service, e.g. <client>.yourdomain.com).
# The page's own "Sign in" link is a hardcoded absolute URL to this
# bench's login page for local dev — repoint it at each real client's
# actual domain before that client's launch, same spirit as rebuilding
# the demo guides with a real client's names (see CLAUDE.md).
image: nginx:alpine
restart: unless-stopped
volumes:
- ./bettersightbox-index.html:/usr/share/nginx/html/index.html:ro
ports:
- ${MARKETING_PUBLISH_PORT:-8091}:80
backend-billing:
# Pre-built and pushed via backend/build.sh — the VPS only ever pulls,
# never builds, same build-locally-test-locally-ship-the-tested-artifact
# pattern as CUSTOM_IMAGE/erpnext-image/ below. BACKEND_BILLING_IMAGE
# defaults to a bare local tag (no registry path) for local dev; set it
# to a real registry path (see .env.example) once deploying for real.
image: ${BACKEND_BILLING_IMAGE:-sightbox-backend-billing}:${BACKEND_BILLING_TAG:-latest}
pull_policy: ${BACKEND_BILLING_PULL_POLICY:-never}
restart: unless-stopped
# Plain environment: vars, not env_file: ./backend/.env — confirmed the
# hard way against a real Dokploy AutoDeploy: Dokploy deletes and
# re-clones the whole git checkout on every deploy, so a file living
# inside it (as env_file: pointed at) never survives to the next
# deploy. Dokploy's own Environment tab variables, by contrast, are
# stored in Dokploy's own database and rewritten fresh into a .env next
# to this compose file on every deploy, independent of the git clone —
# the one mechanism here that's actually designed to persist. These
# four values are simple enough (no multi-line content, nothing
# structured) to move there outright; see .env.example.
environment:
TENANTS_CONFIG_PATH: ${TENANTS_CONFIG_PATH:-tenants.json}
SENTRY_DSN: ${SENTRY_DSN:-}
ENVIRONMENT: ${ENVIRONMENT:-production}
STATE_STORE_PATH: ${STATE_STORE_PATH:-/data/state.db}
volumes:
- billing-state:/data
# Per-tenant credentials, mounted read-only at runtime — never baked
# into the image (see backend/.dockerignore). Multi-tenant billing:
# every client's Frappe API key/secret and Stripe webhook secret live
# here, one JSON object per tenant slug (see backend/tenants.example.json).
#
# TENANTS_JSON_PATH, not a hardcoded ./backend/tenants.json — confirmed
# the hard way: Dokploy deletes and re-clones the whole git checkout
# (including backend/) on every AutoDeploy, so a file living inside it
# never survives to the next deploy. Worse, Docker silently creates an
# empty DIRECTORY at a bind-mount source that doesn't exist yet rather
# than failing, which then crashes the app with a confusing
# IsADirectoryError instead of a clear missing-file error. The default
# below (./backend/tenants.json) is correct for local dev, where the
# checkout is stable; production must override this in .env to an
# absolute path inside $SIGHTBOX_DATA_DIR (e.g.
# /opt/sightbox/data/tenants.json) — outside the wiped checkout, and
# already covered by the nightly backup since it's already inside the
# directory backup.sh tars. See .env.example and
# INSTALLATION_PLAYBOOK.md Stage 1.
#
# Explicit long-form (type: bind), not the short-form
# "source:target:ro" string — confirmed the hard way:
# generate-dokploy-compose.sh's --no-interpolate flag (needed so
# Dokploy's own Environment tab keeps control of these values, see
# that script's header) leaves this source as a literal, unresolved
# "${TENANTS_JSON_PATH:-...}" string. `docker compose config` can't
# tell that's a path when it can't interpolate it, and silently
# normalizes the short form to type: volume instead of type: bind —
# Dokploy then rejects it as "refers to undefined volume". Declaring
# type: bind explicitly here removes the guesswork entirely.
- type: bind
source: ${TENANTS_JSON_PATH:-./backend/tenants.json}
target: /app/tenants.json
read_only: true
depends_on:
- backend
ports:
- ${BILLING_PUBLISH_PORT:-8001}:8000
volumes:
# Plain Docker-managed volumes by default — safe on any host OS. For the
# real Linux deployment target, layer docker-compose.data-dir.yml on top
# (-f docker-compose.yml -f docker-compose.data-dir.yml) to redirect these
# to one visible, backup-able host directory instead. Never do that layering
# for local dev on macOS/Windows: Docker Desktop's bind mount runs the
# container's view of that directory through the *host's* filesystem
# semantics, and macOS's default filesystem is case-insensitive — confirmed
# the hard way: MariaDB silently sets lower_case_table_names=2 against a
# case-insensitive filesystem, which does not match how this data's tables
# were actually created, and every query starts failing with "doesn't exist
# in engine". Docker's own named-volume storage (used here) lives inside
# the Desktop VM's Linux filesystem regardless of host OS, so it never hits
# this — only a host bind mount can. See playbook/BACKUP_RESTORE.md.
billing-state:
sites:
db-data:
redis-queue-data: