diff options
Diffstat (limited to 'deploy.sh')
| -rwxr-xr-x | deploy.sh | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -81,3 +81,17 @@ else ssh "$DEPLOY_HOST" 'cat ~/homepage/nginx.conf.prev > ~/homepage/nginx.conf' 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 |
