Files
leggenda-del-regolo/Dockerfile
T

27 lines
1.2 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
# Le immagini e i font citati da index.html e style.css prendono ?v=<versione>, come quelli caricati dal codice.
RUN cd /usr/share/nginx/html \
&& V=$(sed -n "s/^export const VERSION = '\([0-9.]*\)';$/\1/p" src/version.js) \
&& test -n "$V" \
&& 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