Skip to content

Commit 1f3d930

Browse files
Fix rebuild
1 parent fca678c commit 1f3d930

2 files changed

Lines changed: 37 additions & 16 deletions

File tree

scripts/rebuild_frontend.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,26 +319,43 @@ copy_tree_via_staged_tar() {
319319
echo "rebuild_frontend.sh: extracting staged tar into web:${dest} ..."
320320
docker compose exec -T web bash -lc \
321321
"rm -rf '${dest}' && mkdir -p '${dest}' && tar -xf '${container_tar}' -C '${dest}' && rm -f '${container_tar}'"
322+
verify_container_extract_fingerprint "${dest}" "${dest}"
322323
}
323324

324-
run_collectstatic_into_volume() {
325-
echo "rebuild_frontend.sh: running collectstatic into ${CONTAINER_STATIC_ROOT_FRONTEND} ..."
326-
docker compose exec -T web bash -lc \
327-
"rm -rf '${CONTAINER_STATIC_ROOT_FRONTEND}' && /usr/local/bin/python3 hpcperfstats/site/manage.py collectstatic --noinput"
325+
verify_container_extract_fingerprint() {
326+
local dest="$1"
327+
local label="$2"
328+
local host_fp container_fp probe="${dest}/machine/index.html"
329+
330+
host_fp="$(frontend_build_fingerprint "${STATIC_FRONTEND}/machine/index.html")"
331+
container_fp="$(
332+
docker compose exec -T web bash -lc \
333+
"grep -oE 'page-[0-9a-f]+\\.js' '${probe}' 2>/dev/null | head -n 1 || echo unknown"
334+
)"
335+
336+
if [[ "${host_fp}" != "${container_fp}" ]]; then
337+
echo "rebuild_frontend.sh: ${label} fingerprint mismatch after extract" >&2
338+
echo " host: ${host_fp} (${STATIC_FRONTEND}/machine/index.html)" >&2
339+
echo " container: ${container_fp} (${probe})" >&2
340+
return 1
341+
fi
342+
343+
echo "Verified extract fingerprint for ${label} (${container_fp})"
328344
}
329345

330-
deploy_frontend_via_collectstatic() {
331-
echo "rebuild_frontend.sh: podman-compose deploy — stage image source tree, then collectstatic to nginx volume"
346+
deploy_frontend_via_staged_volume() {
347+
echo "rebuild_frontend.sh: podman-compose — staged tar direct to nginx volume (staticfiles_data)"
348+
copy_tree_via_staged_tar "${CONTAINER_STATIC_ROOT_FRONTEND}"
349+
echo "rebuild_frontend.sh: syncing image source tree for future image rebuilds ..."
332350
copy_tree_via_staged_tar "${CONTAINER_STATIC_FRONTEND}"
333-
run_collectstatic_into_volume
334351
}
335352

336353
print_podman_deploy_fallback() {
337354
cat <<EOF >&2
338355
rebuild_frontend.sh: manual podman fallback (from git checkout):
339356
tar -cf /tmp/hps-frontend.tar -C hpcperfstats/site/hpcperfstats_site/static/frontend .
340357
podman cp /tmp/hps-frontend.tar hpcperfstats_web_1:/tmp/hps-frontend.tar
341-
docker compose exec web bash -lc 'rm -rf ${CONTAINER_STATIC_FRONTEND} && mkdir -p ${CONTAINER_STATIC_FRONTEND} && tar -xf /tmp/hps-frontend.tar -C ${CONTAINER_STATIC_FRONTEND} && rm -f /tmp/hps-frontend.tar && rm -rf ${CONTAINER_STATIC_ROOT_FRONTEND} && /usr/local/bin/python3 hpcperfstats/site/manage.py collectstatic --noinput'
358+
docker compose exec web bash -lc 'rm -rf ${CONTAINER_STATIC_ROOT_FRONTEND} && mkdir -p ${CONTAINER_STATIC_ROOT_FRONTEND} && tar -xf /tmp/hps-frontend.tar -C ${CONTAINER_STATIC_ROOT_FRONTEND} && rm -f /tmp/hps-frontend.tar'
342359
EOF
343360
}
344361

@@ -362,8 +379,7 @@ copy_tree_into_container() {
362379
exit 1
363380
fi
364381

365-
# podman-compose: stdin tar / compose cp / direct volume copy are unreliable; stage the
366-
# image source tree and refresh STATIC_ROOT/frontend with collectstatic (same as startup).
382+
# podman-compose: stage tar, extract with compose exec onto the destination path.
367383
echo "rebuild_frontend.sh: copying via staged tar + compose exec extract → ${dest}"
368384
copy_tree_via_staged_tar "${dest}"
369385
}
@@ -372,7 +388,7 @@ copy_frontend_into_web() {
372388
cd "${REPO_ROOT}"
373389

374390
if compose_backend_is_podman; then
375-
deploy_frontend_via_collectstatic
391+
deploy_frontend_via_staged_volume
376392
return
377393
fi
378394

scripts/test_rebuild_frontend_verify.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cleanup() {
1515
}
1616
trap cleanup EXIT
1717

18-
for fn in copy_frontend_into_web compose_cp_supported web_container_ref verify_container_frontend_matches_host verify_proxy_frontend_matches_web copy_tree_via_staged_tar compose_backend_is_podman deploy_frontend_via_collectstatic; do
18+
for fn in copy_frontend_into_web compose_cp_supported web_container_ref verify_container_frontend_matches_host verify_proxy_frontend_matches_web copy_tree_via_staged_tar compose_backend_is_podman deploy_frontend_via_staged_volume verify_container_extract_fingerprint; do
1919
if ! declare -F "${fn}" >/dev/null; then
2020
echo "expected ${fn} to be defined in rebuild_frontend.sh" >&2
2121
exit 1
@@ -47,13 +47,18 @@ if ! grep -q 'PROXY_STATIC_ROOT_FRONTEND' "${REBUILD_SCRIPT}"; then
4747
exit 1
4848
fi
4949

50-
if ! grep -q 'deploy_frontend_via_collectstatic' "${REBUILD_SCRIPT}"; then
51-
echo "expected podman collectstatic deploy path in rebuild_frontend.sh" >&2
50+
if ! grep -q 'deploy_frontend_via_staged_volume' "${REBUILD_SCRIPT}"; then
51+
echo "expected podman staged-volume deploy path in rebuild_frontend.sh" >&2
5252
exit 1
5353
fi
5454

55-
if ! grep -q 'run_collectstatic_into_volume' "${REBUILD_SCRIPT}"; then
56-
echo "expected collectstatic volume refresh for podman in rebuild_frontend.sh" >&2
55+
if ! grep -q 'verify_container_extract_fingerprint' "${REBUILD_SCRIPT}"; then
56+
echo "expected post-extract fingerprint verify in rebuild_frontend.sh" >&2
57+
exit 1
58+
fi
59+
60+
if grep -q 'deploy_frontend_via_collectstatic' "${REBUILD_SCRIPT}"; then
61+
echo "podman hot deploy must not rely on collectstatic (conflict skips leave stale frontend)" >&2
5762
exit 1
5863
fi
5964

0 commit comments

Comments
 (0)