Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiECdCPptNRwbVzjzHbohi
35 lines
1.8 KiB
Docker
35 lines
1.8 KiB
Docker
# LA LEGGENDA DEL REGOLO: gioco statico servito da nginx.
|
|
FROM nginx:1.27-alpine
|
|
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY index.html style.css /usr/share/nginx/html/
|
|
COPY src /usr/share/nginx/html/src
|
|
COPY assets/scenes /usr/share/nginx/html/assets/scenes
|
|
COPY assets/characters /usr/share/nginx/html/assets/characters
|
|
COPY assets/audio /usr/share/nginx/html/assets/audio
|
|
COPY assets/icons /usr/share/nginx/html/assets/icons
|
|
COPY assets/fonts /usr/share/nginx/html/assets/fonts
|
|
COPY assets/voices /usr/share/nginx/html/assets/voices
|
|
COPY assets/credits /usr/share/nginx/html/assets/credits
|
|
COPY assets/effects /usr/share/nginx/html/assets/effects
|
|
COPY assets/closeups /usr/share/nginx/html/assets/closeups
|
|
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=<versione>, 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
|
|
|
|
EXPOSE 80
|
|
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
|