From c96dec4692333c3b54f1de6a50034371ca77e877 Mon Sep 17 00:00:00 2001 From: Andrea Manzi Date: Wed, 28 Oct 2026 19:55:16 +0100 Subject: [PATCH] =?UTF-8?q?Docker:=20al=20=3Fv=3D=20degli=20asset=20l'impr?= =?UTF-8?q?onta=20del=20contenuto=20di=20assets/,=20cos=C3=AC=20uno=20sfon?= =?UTF-8?q?do=20rifatto=20senza=20bump=20non=20resta=20nella=20cache=20lun?= =?UTF-8?q?ga=20del=20browser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GiECdCPptNRwbVzjzHbohi --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index dbe692f..2aabefa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,9 +17,15 @@ COPY assets/favicon /usr/share/nginx/html/assets/favicon COPY assets/video /usr/share/nginx/html/assets/video # Le immagini e i font citati da index.html e style.css prendono ?v=, come quelli caricati dal codice. +# Alla versione si aggiunge l'impronta del contenuto di assets/: uno sfondo rifatto senza cambiare versione (in +# locale, fra un bump e l'altro) ha un indirizzo nuovo, e il browser non tiene quello vecchio dalla cache lunga. RUN cd /usr/share/nginx/html \ && V=$(sed -n "s/^export const VERSION = '\([0-9.]*\)';$/\1/p" src/version.js) \ && test -n "$V" \ + && H=$(find assets -type f -exec md5sum {} + | sort -k2 | md5sum | cut -c1-8) \ + && sed -i -E 's#v=\$\{VERSION\}#v=${VERSION}-'"$H"'#' src/version.js \ + && grep -q "VERSION}-$H" src/version.js \ + && V="$V-$H" \ && sed -i -E "s#url\((assets/[^)]*)\)#url(\1?v=$V)#g" style.css \ && sed -i -E "s#src=\"(assets/[^\"]*)\"#src=\"\1?v=$V\"#g" index.html \ && grep -q "?v=$V" style.css && grep -q "?v=$V" index.html