Fix marketing container staleness for real: recreate on every deploy, not just HTML edits
Found live: box.bettersight.io's hero image 404'd again after a deploy that touched zero marketing-related files (a dev.sh/prod.sh/tests-only commit). Root cause was deeper than the original content-hash fix assumed — Dokploy re-clones the ENTIRE git checkout on every deploy, not just ones that change bettersightbox-index.html, which orphans marketing's assets/ directory bind mount (the container's mount still points at the old, now-deleted directory inode) whenever the container itself isn't also recreated in that same deploy. A hash of one file's content only caught deploys that touched that file. Fix: generate-dokploy-compose.sh now bakes in the current git commit SHA instead, so the content-hash label (and the recreate it forces) changes on every single deploy, unconditionally. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
This commit is contained in:
parent
d22b628945
commit
c8be366015
14
CLAUDE.md
14
CLAUDE.md
|
|
@ -158,10 +158,16 @@ sightbox/
|
|||
(`include:` resolved, `frappe_docker`'s files merged in) by
|
||||
`./generate-dokploy-compose.sh`. Regenerate it any time
|
||||
`docker-compose.yml` changes, `frappe_docker`'s pinned commit moves
|
||||
(`.gitmodules`), **or `website/website-bettersightbox/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
|
||||
(`.gitmodules`), or — really — any time you deploy at all: it bakes the
|
||||
current git commit SHA into the `marketing` service's content-hash
|
||||
label so Dokploy's AutoDeploy recreates that container on every single
|
||||
deploy, not just ones touching `bettersightbox-index.html`. Confirmed
|
||||
the hard way that a content-only hash wasn't enough — Dokploy re-clones
|
||||
the WHOLE checkout on every deploy regardless of what changed, which
|
||||
orphans `marketing`'s `assets/` directory bind mount (building.jpg
|
||||
starts 404ing) whenever the container itself doesn't also get
|
||||
recreated in that same deploy. `scripts/prod.sh` already runs this
|
||||
automatically on every ship, so this isn't a step you need to remember
|
||||
(confirmed the hard way — see that service's own comment in
|
||||
`docker-compose.yml`). It's committed, generated output — never
|
||||
hand-edited.
|
||||
|
|
|
|||
|
|
@ -60,25 +60,43 @@ 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
|
||||
# website-bettersightbox/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.
|
||||
# content-hash label — confirmed the hard way, in production, TWICE:
|
||||
# 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 on
|
||||
# EVERY deploy, not just ones that touch this HTML file — never had a
|
||||
# reason to recreate this one container on its own.
|
||||
#
|
||||
# First confirmed failure mode: the container kept serving the OLD
|
||||
# index.html indefinitely. Fixed by hashing bettersightbox-index.html
|
||||
# and baking the hash in as this label's literal value — but that
|
||||
# only forces a recreate on deploys that change THAT one file.
|
||||
#
|
||||
# Second, separate failure mode, confirmed later: a deploy that
|
||||
# changed unrelated files (no content-hash change at all) still
|
||||
# re-cloned the checkout, which orphans the assets/ directory bind
|
||||
# mount below — the running container's mount still points at the
|
||||
# OLD, now-deleted directory inode, so /assets/building.jpg starts
|
||||
# 404ing even though index.html itself keeps serving fine (a single
|
||||
# FILE bind mount doesn't have this problem; a DIRECTORY one does).
|
||||
# generate-dokploy-compose.sh now bakes in the current git commit SHA
|
||||
# instead of a content hash — see that script's own comment — so this
|
||||
# container gets recreated on every deploy, full stop, not just ones
|
||||
# that happen to touch index.html.
|
||||
#
|
||||
# The default below (${MARKETING_DEPLOY_TOKEN:-dev}) only applies to
|
||||
# local dev, where scripts/dev.sh force-recreates this service
|
||||
# unconditionally anyway (see its own comment) rather than relying on
|
||||
# this label changing at all.
|
||||
#
|
||||
# Everything box.bettersight.io-specific lives under
|
||||
# website/website-bettersightbox/ now — colocated with its sibling
|
||||
# marketing sites (bi.bettersight.io, bettersight.io) under website/,
|
||||
# rather than loose at the repo root.
|
||||
labels:
|
||||
- "content-hash=${MARKETING_HTML_HASH:-dev}"
|
||||
- "content-hash=${MARKETING_DEPLOY_TOKEN:-dev}"
|
||||
volumes:
|
||||
- ./website/website-bettersightbox/bettersightbox-index.html:/usr/share/nginx/html/index.html:ro
|
||||
# ./assets/ holds images the page references directly (e.g. the hero
|
||||
|
|
|
|||
|
|
@ -56,15 +56,28 @@
|
|||
# website/website-bettersightbox/bettersightbox-index.html changes, or
|
||||
# frappe_docker is repointed at a different pinned commit (see
|
||||
# .gitmodules) — this file is generated output, never hand-edited.
|
||||
# scripts/prod.sh runs it on every ship, so in practice it's regenerated
|
||||
# (and MARKETING_DEPLOY_TOKEN below changes, see that variable's own
|
||||
# comment) on every single deploy regardless of what you were actually
|
||||
# shipping.
|
||||
#
|
||||
# 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.
|
||||
# MARKETING_DEPLOY_TOKEN: baked in below as a literal value (not left as
|
||||
# ${VAR}, unlike everything else --no-interpolate preserves) — forces
|
||||
# Dokploy's AutoDeploy to recreate the marketing container on every
|
||||
# deploy. Confirmed the hard way that this has to be EVERY deploy, not
|
||||
# just ones that change bettersightbox-index.html's content (an earlier
|
||||
# version of this hashed just that one file's bytes): Dokploy deletes and
|
||||
# re-clones the ENTIRE git checkout on every deploy, which orphans
|
||||
# marketing's assets/ directory bind mount (the container's existing
|
||||
# mount still points at the old, now-deleted directory's inode) whenever
|
||||
# the container itself isn't ALSO recreated in that same deploy — a
|
||||
# content-only hash misses every deploy that doesn't touch that one file,
|
||||
# even though the re-clone (and the orphaning) happens regardless. A
|
||||
# fresh git commit SHA changes on every real ship, so it's a correct
|
||||
# "did a deploy happen" signal in a way file-content hashing never was.
|
||||
# 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 on every deploy.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
|
|
@ -72,13 +85,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||
cd "$SCRIPT_DIR"
|
||||
|
||||
OUT="docker-compose.dokploy.yml"
|
||||
MARKETING_HTML_HASH="$(sha256sum website/website-bettersightbox/bettersightbox-index.html | cut -c1-12)"
|
||||
MARKETING_DEPLOY_TOKEN="$(git rev-parse --short HEAD)"
|
||||
|
||||
{
|
||||
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, or"
|
||||
echo "# after changing website-bettersightbox/bettersightbox-index.html (see MARKETING_HTML_HASH above)."
|
||||
echo "# any other time you deploy (see MARKETING_DEPLOY_TOKEN 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)."
|
||||
|
|
@ -93,8 +106,8 @@ text = re.sub(r'^(\s*)- path: (.+)\n\s*required: (?:true|false)\s*\$', lambda m:
|
|||
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}/"
|
||||
| sed "s/\${MARKETING_DEPLOY_TOKEN:-dev}/${MARKETING_DEPLOY_TOKEN}/"
|
||||
} > "$OUT"
|
||||
|
||||
echo "Wrote ${OUT} (marketing content-hash: ${MARKETING_HTML_HASH})."
|
||||
echo "Wrote ${OUT} (marketing deploy token: ${MARKETING_DEPLOY_TOKEN})."
|
||||
echo "Set Dokploy's Compose Path to ./${OUT}, not ./docker-compose.yml, and redeploy."
|
||||
|
|
|
|||
|
|
@ -206,11 +206,13 @@ Applying the pattern above here, concretely:
|
|||
`include:` directive ("Additional property include is not allowed" — matches two open,
|
||||
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` or `website/website-bettersightbox/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).
|
||||
same deployment pre-flattened by `./generate-dokploy-compose.sh` — regenerate it on every
|
||||
deploy (`scripts/prod.sh` already does this automatically), never hand-edit it. It bakes the
|
||||
current git commit SHA into the `marketing` service's content-hash label so AutoDeploy
|
||||
recreates that container on every deploy, not just ones touching `bettersightbox-index.html`
|
||||
— confirmed the hard way that a content-only hash missed deploys that re-clone the checkout
|
||||
(which Dokploy does on EVERY deploy) without changing that one file, orphaning the service's
|
||||
`assets/` directory bind mount; 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` —
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
# scripts/prod.sh for shipping what you've tested here.
|
||||
#
|
||||
# What happens when this runs, in order:
|
||||
# 1. ./generate-dokploy-compose.sh — keeps docker-compose.dokploy.yml's
|
||||
# marketing content-hash in sync as you edit website/website-bettersightbox/
|
||||
# bettersightbox-index.html, so there's nothing new for prod.sh to
|
||||
# auto-commit at ship time. Not committed here — dev.sh never
|
||||
# touches git; prod.sh is the only one that commits, gated behind
|
||||
# its own clean-tree/test checks.
|
||||
# 1. ./generate-dokploy-compose.sh — regenerates docker-compose.dokploy.yml,
|
||||
# including a fresh marketing content-hash label (the current git
|
||||
# commit SHA — see that script's own comment for why it has to be
|
||||
# every deploy, not just bettersightbox-index.html edits). Not
|
||||
# committed here — dev.sh never touches git; prod.sh is the only one
|
||||
# that commits, gated behind its own clean-tree/test checks.
|
||||
# 2. ./erpnext-image/build.sh — CUSTOM_IMAGE in the root .env is a bare
|
||||
# local tag (not a registry path), so this takes the local branch:
|
||||
# builds sightbox-erpnext for this machine's own architecture, no push.
|
||||
|
|
|
|||
|
|
@ -34,14 +34,17 @@
|
|||
# BEFORE step 3's own regenerate-and-commit, so that auto-commit is
|
||||
# never mixed in with unrelated uncommitted work).
|
||||
# 3. Regenerates docker-compose.dokploy.yml (./generate-dokploy-compose.sh)
|
||||
# and auto-commits it if the content-hash (or anything else) changed —
|
||||
# this is the one thing this script commits on its own, scoped to
|
||||
# exactly this generated file. Without this, an edit to
|
||||
# website/website-bettersightbox/bettersightbox-index.html with no other
|
||||
# docker-compose.yml change
|
||||
# would ship with a stale content-hash and the marketing container
|
||||
# would silently never get recreated — see that service's own comment
|
||||
# in docker-compose.yml for the full story.
|
||||
# and auto-commits it — this is the one thing this script commits on
|
||||
# its own, scoped to exactly this generated file. The marketing
|
||||
# content-hash label is the current git commit SHA (see that
|
||||
# script's own comment), so this file changes on every single ship,
|
||||
# guaranteeing Dokploy recreates the marketing container on every
|
||||
# deploy — not just ones that touch bettersightbox-index.html.
|
||||
# Without this, the marketing container's assets/ directory bind
|
||||
# mount gets silently orphaned by Dokploy's own full-checkout
|
||||
# re-clone on ANY deploy, breaking things like the hero background
|
||||
# image with no error anywhere — see that service's own comment in
|
||||
# docker-compose.yml for the full story.
|
||||
# 4. Loads scripts/.env.prod — exits if it doesn't exist yet; otherwise
|
||||
# exports the real CUSTOM_IMAGE/CUSTOM_TAG/BACKEND_BILLING_IMAGE/
|
||||
# BACKEND_BILLING_TAG registry paths into this shell.
|
||||
|
|
|
|||
Loading…
Reference in New Issue