From 219af05c744ae625db8b8f02b8dac670d0218eaa Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Sun, 4 Oct 2026 14:05:40 -0400 Subject: [PATCH] Fix marketing container never recreating on AutoDeploy Confirmed the hard way, live in production: Docker Compose only recreates a container when its own service definition changes (image, env, labels...), never from a bind-mounted file's content changing on disk by itself. marketing's service definition never changes between deploys, so Dokploy's AutoDeploy -- which wipes and re-clones the whole git checkout, including bettersightbox-index.html, on every push -- had never once recreated that container. It kept serving a September-dated, weeks-stale copy of the page indefinitely, orphaned from the fresh file sitting right next to it on disk, through every single deploy since Stage 1. generate-dokploy-compose.sh now computes a real sha256-based hash of bettersightbox-index.html and bakes it into the marketing service as a literal content-hash label -- the one value in the whole generated file that's deliberately NOT left as a live ${VAR} reference, since its only job is to actually change when the file's content changes, giving Compose's own diffing a real reason to recreate the container. Local dev (where this bug doesn't apply, no AutoDeploy wipe-and-reclone cycle) keeps the ${MARKETING_HTML_HASH:-dev} default. Documented in CLAUDE.md and CICD_PLAYBOOK.md: regenerate docker-compose.dokploy.yml any time bettersightbox-index.html changes, not just when docker-compose.yml itself changes -- skipping it silently leaves the marketing page stale with no error anywhere. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y --- CLAUDE.md | 10 ++++++++-- docker-compose.dokploy.yml | 5 ++++- docker-compose.yml | 14 ++++++++++++++ generate-dokploy-compose.sh | 24 ++++++++++++++++++------ playbook/CICD_PLAYBOOK.md | 6 +++++- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index bd09e1a..de948ab 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -145,8 +145,14 @@ sightbox/ file. `docker-compose.dokploy.yml` is the same deployment, pre-flattened (`include:` resolved, `frappe_docker`'s files merged in) by `./generate-dokploy-compose.sh`. Regenerate it any time - `docker-compose.yml` changes or `frappe_docker`'s pinned commit moves - (`.gitmodules`); it's committed, generated output — never hand-edited. + `docker-compose.yml` changes, `frappe_docker`'s pinned commit moves + (`.gitmodules`), **or `bettersightbox-index.html` changes** — the last + one bakes a fresh content-hash label into the `marketing` service so + Dokploy's AutoDeploy actually recreates that container; skipping it + means the marketing page silently keeps serving old content indefinitely + (confirmed the hard way — see that service's own comment in + `docker-compose.yml`). It's committed, generated output — never + hand-edited. - **One VPS can host multiple clients.** `docker compose up` stands up one bench (the shared Frappe/ERPNext containers, MariaDB, Redis, and the `backend-billing` service) — it doesn't imply one client. Each client is diff --git a/docker-compose.dokploy.yml b/docker-compose.dokploy.yml index 35f55b9..df17312 100644 --- a/docker-compose.dokploy.yml +++ b/docker-compose.dokploy.yml @@ -1,6 +1,7 @@ # GENERATED FILE — do not edit by hand. # Produced by ./generate-dokploy-compose.sh from docker-compose.yml + the -# frappe_docker files it includes. Regenerate after changing either. +# frappe_docker files it includes. Regenerate after changing either, or +# after changing bettersightbox-index.html (see MARKETING_HTML_HASH above). # This is what Dokploy's Compose Path should point to — not # docker-compose.yml itself, which Dokploy's validator rejects (see # this script's own header comment for why). @@ -144,6 +145,8 @@ services: volume: {} marketing: image: nginx:alpine + labels: + - content-hash=9156ba6f79dd networks: default: null ports: diff --git a/docker-compose.yml b/docker-compose.yml index 46f05da..a08d8a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,6 +60,20 @@ services: # the demo guides with a real client's names (see CLAUDE.md). image: nginx:alpine restart: unless-stopped + # content-hash label — confirmed the hard way, in production: Docker + # Compose only recreates a container when its own service DEFINITION + # changes (image, env, labels, ...), never from a bind-mounted file's + # content changing on disk by itself. Since this service's definition + # is otherwise 100% static, Dokploy's AutoDeploy — which wipes and + # re-clones the whole git checkout, including this HTML file, on every + # deploy — never had a reason to recreate this one container, so it + # kept running against the OLD file's now-orphaned inode indefinitely. + # generate-dokploy-compose.sh computes a real hash of + # bettersightbox-index.html and bakes it in here as a literal value; + # the default below (${MARKETING_HTML_HASH:-dev}) only applies to + # local dev, where this doesn't matter. + labels: + - "content-hash=${MARKETING_HTML_HASH:-dev}" volumes: - ./bettersightbox-index.html:/usr/share/nginx/html/index.html:ro ports: diff --git a/generate-dokploy-compose.sh b/generate-dokploy-compose.sh index ab80a4f..580792a 100755 --- a/generate-dokploy-compose.sh +++ b/generate-dokploy-compose.sh @@ -52,9 +52,18 @@ # which is what every `depends_on` entry in this file actually uses. # # Usage: ./generate-dokploy-compose.sh -# Run this any time docker-compose.yml changes, or any time frappe_docker -# is repointed at a different pinned commit (see .gitmodules) — this file -# is generated output, never hand-edited. +# Run this any time docker-compose.yml changes, bettersightbox-index.html +# changes, or frappe_docker is repointed at a different pinned commit (see +# .gitmodules) — this file is generated output, never hand-edited. +# +# MARKETING_HTML_HASH: baked in below as a literal value (not left as +# ${VAR}, unlike everything else --no-interpolate preserves) — this is +# what actually forces Dokploy's AutoDeploy to recreate the marketing +# container when only bettersightbox-index.html changed; see that +# service's own comment in docker-compose.yml for the full story. Every +# other variable stays a live ${VAR} reference on purpose; this one +# specifically must not, since its entire job is to be a different literal +# string every time the file's content changes. set -euo pipefail @@ -62,11 +71,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" OUT="docker-compose.dokploy.yml" +MARKETING_HTML_HASH="$(sha256sum bettersightbox-index.html | cut -c1-12)" { echo "# GENERATED FILE — do not edit by hand." echo "# Produced by ./generate-dokploy-compose.sh from docker-compose.yml + the" - echo "# frappe_docker files it includes. Regenerate after changing either." + echo "# frappe_docker files it includes. Regenerate after changing either, or" + echo "# after changing bettersightbox-index.html (see MARKETING_HTML_HASH above)." echo "# This is what Dokploy's Compose Path should point to — not" echo "# docker-compose.yml itself, which Dokploy's validator rejects (see" echo "# this script's own header comment for why)." @@ -80,8 +91,9 @@ text = re.sub(r'^(\s*)- path: (.+)\n\s*required: (?:true|false)\s*\$', lambda m: # depends_on: drop required:, keep condition: (Dokploy rejection #3). text = re.sub(r'^(\s*condition: .+)\n\s*required: (?:true|false)\s*\$', r'\1', text, flags=re.MULTILINE) sys.stdout.write(text) -" +" \ + | sed "s/\${MARKETING_HTML_HASH:-dev}/${MARKETING_HTML_HASH}/" } > "$OUT" -echo "Wrote ${OUT}." +echo "Wrote ${OUT} (marketing content-hash: ${MARKETING_HTML_HASH})." echo "Set Dokploy's Compose Path to ./${OUT}, not ./docker-compose.yml, and redeploy." diff --git a/playbook/CICD_PLAYBOOK.md b/playbook/CICD_PLAYBOOK.md index 7531147..d0775db 100644 --- a/playbook/CICD_PLAYBOOK.md +++ b/playbook/CICD_PLAYBOOK.md @@ -207,7 +207,11 @@ Applying the pattern above here, concretely: unresolved Dokploy issues, [#3116](https://github.com/Dokploy/dokploy/issues/3116) and [#1727](https://github.com/Dokploy/dokploy/issues/1727)). `docker-compose.dokploy.yml` is the same deployment pre-flattened by `./generate-dokploy-compose.sh` — regenerate it any time - `docker-compose.yml` changes, never hand-edit it. Also enable this Application's **Enable + `docker-compose.yml` or `bettersightbox-index.html` changes, never hand-edit it (the latter + bakes a fresh content-hash into the `marketing` service specifically so AutoDeploy actually + recreates that container — skipping it leaves the marketing page serving stale content + indefinitely, confirmed the hard way; see `docker-compose.yml`'s own comment on that service). + Also enable this Application's **Enable Submodules** toggle (confirmed working against our `frappe_docker` mirror submodule — see `.gitmodules`). Set environment variables to match `.env.example`/`backup/.env.example` — `SIGHTBOX_DATA_DIR`, `SENTRY_DSN`, `ENVIRONMENT=production`, `BACKEND_BILLING_IMAGE`/`_TAG`,