feat: add a simple cache versioning system in Dockerfile

This commit is contained in:
Alexis Fourmaux 2026-05-11 22:09:08 +02:00
parent 97ca3813e8
commit 772063113b
2 changed files with 8 additions and 1 deletions

View file

@ -3,4 +3,11 @@ FROM nginx:alpine
COPY public/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN HTML=/usr/share/nginx/html/index.html && \
for f in $(find /usr/share/nginx/html/assets -name "*.css" -o -name "*.js"); do \
hash=$(md5sum "$f" | cut -c1-8); \
rel="${f#/usr/share/nginx/html}"; \
sed -i "s|${rel}\"|${rel}?v=${hash}\"|g" "$HTML"; \
done
EXPOSE 80

View file

@ -11,7 +11,7 @@ server {
location /assets/ {
expires 1y;
add_header Cache-Control "public";
add_header Cache-Control "public, immutable";
}
location = /index.html {