summaryrefslogtreecommitdiff
path: root/deploy-docker.sh
diff options
context:
space:
mode:
authorVoid Agent <void@jayrup.hermes>2026-10-22 23:13:43 +0100
committerVoid Agent <void@jayrup.hermes>2026-10-22 23:13:43 +0100
commit0eea672450447fc678f8073307a2e9139dd85616 (patch)
tree1eb6409048a98a1db8e28129b5914e9f05403096 /deploy-docker.sh
parent1e58fcb98fd17dbec3a2b477d3737b83101a18b5 (diff)
deploy: detect a detached nginx.conf bind mount instead of trusting reload
The single-file mount pins the inode present when the container started. A rename-based write leaves the container serving stale bytes while nginx -t validates them, which is exactly how the previous deploy reported success with an unchanged config. Compare the host and in-container checksums after the reload and restart the container to re-resolve the path on mismatch.
Diffstat (limited to 'deploy-docker.sh')
-rwxr-xr-xdeploy-docker.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/deploy-docker.sh b/deploy-docker.sh
index 12d4a54..0d1100d 100755
--- a/deploy-docker.sh
+++ b/deploy-docker.sh
@@ -89,4 +89,18 @@ else
exit 1
fi
+# A single-file bind mount pins whatever inode existed when the container
+# started. If the host file was ever replaced by rename (an older deploy, an
+# editor, `cp`), the container keeps serving the old bytes while `nginx -t`
+# validates them happily. Compare what the container actually sees and restart
+# to re-resolve the path if it has drifted.
+HOST_MD5="$(ssh "$DEPLOY_HOST" 'md5sum ~/homepage/nginx.conf' | cut -d' ' -f1)"
+CTR_MD5="$(ssh "$DEPLOY_HOST" 'docker exec homepage md5sum /etc/nginx/conf.d/default.conf' | cut -d' ' -f1)"
+if [ "$HOST_MD5" != "$CTR_MD5" ]; then
+ echo "!! container is serving a stale nginx.conf (bind mount detached) - restarting" >&2
+ ssh "$DEPLOY_HOST" 'docker restart homepage'
+ CTR_MD5="$(ssh "$DEPLOY_HOST" 'docker exec homepage md5sum /etc/nginx/conf.d/default.conf' | cut -d' ' -f1)"
+ [ "$HOST_MD5" = "$CTR_MD5" ] || { echo "!! nginx.conf still not mounted - aborting" >&2; exit 1; }
+fi
+
echo ">> deploy OK ($SHORT_SHA)"