The React bundle hash changes every time the UI is rebuilt. With the old no-clobber approach, a redeployed container kept serving the old bundle because the static/ directory already existed on the data volume. Fix: always overwrite index.html, asset-manifest.json, and the entire static/ subdirectory from /core/static on every container start. These are build artifacts (not operator-edited content) so overwriting is safe. All other top-level entries (channels/, config/, etc.) remain no-clobber.
55 lines
1.8 KiB
Bash
Executable file
55 lines
1.8 KiB
Bash
Executable file
#!/bin/sh
|
|
# seed-data.sh — boot-time seed of /core/data with Dragon Fork
|
|
# landing page artifacts (index.html, whep-player.html, compiled UI bundle).
|
|
#
|
|
# Runs from the entrypoint before bin/core.
|
|
#
|
|
# Strategy:
|
|
# - Build artifacts (index.html, asset-manifest.json, static/) are ALWAYS
|
|
# overwritten so a redeployed container picks up the new UI bundle even
|
|
# when the data volume already exists. The React bundle hash changes every
|
|
# build, so leaving the old bundle in place would serve a stale UI.
|
|
# - Everything else (channels/, _player/, _playersite/, custom HTML files)
|
|
# is no-clobber so operator-edited content is never lost.
|
|
#
|
|
# Source dir: /core/static (baked by the Dockerfile)
|
|
# Target dir: /core/data (operator-mounted; what Core serves at /)
|
|
|
|
set -e
|
|
|
|
SRC=/core/static
|
|
DST="${CORE_STORAGE_DISK_DIR:-/core/data}"
|
|
|
|
if [ ! -d "$SRC" ]; then
|
|
# No static dir baked — nothing to seed. Fall through silently.
|
|
exit 0
|
|
fi
|
|
|
|
if [ ! -d "$DST" ]; then
|
|
mkdir -p "$DST"
|
|
fi
|
|
|
|
# Always-overwrite entries: build artifacts whose content changes every deploy.
|
|
for always in index.html asset-manifest.json static; do
|
|
src="$SRC/$always"
|
|
dst="$DST/$always"
|
|
[ -e "$src" ] || continue
|
|
if [ -d "$src" ]; then
|
|
cp -Rfp "$src" "$dst"
|
|
else
|
|
cp -fp "$src" "$dst"
|
|
fi
|
|
echo "seed-data: refreshed $always -> $dst"
|
|
done
|
|
|
|
# No-clobber entries: everything else (operator content, player bundles, etc.)
|
|
for f in "$SRC"/* "$SRC"/.[!.]*; do
|
|
[ -e "$f" ] || continue
|
|
name=$(basename "$f")
|
|
# Skip entries already handled above.
|
|
case "$name" in index.html|asset-manifest.json|static) continue ;; esac
|
|
if [ ! -e "$DST/$name" ]; then
|
|
cp -Rp "$f" "$DST/$name"
|
|
echo "seed-data: copied $name -> $DST/$name"
|
|
fi
|
|
done
|