diff options
Diffstat (limited to 'deploy-docker.sh')
| -rwxr-xr-x | deploy-docker.sh | 14 |
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)" |
