A CDN in front of the site caches /style.css for hours, so a redeploy served new HTML with the old stylesheet. The Dockerfile now rewrites the link to style.css?v=<hash> in the built image (source stays unversioned) and fails the build if the rewrite does not apply.
10 lines
469 B
Docker
10 lines
469 B
Docker
FROM caddy:2
|
|
COPY Caddyfile /etc/caddy/Caddyfile
|
|
COPY dist/ /srv/fieldwork/
|
|
|
|
# A CDN in front of the site may cache /style.css for hours. Version its URL by content hash
|
|
# so a changed stylesheet is always fetched fresh. The build fails if the rewrite did not apply.
|
|
RUN h=$(md5sum /srv/fieldwork/style.css | cut -c1-10) \
|
|
&& sed -i "s|href=\"style.css\"|href=\"style.css?v=${h}\"|" /srv/fieldwork/index.html \
|
|
&& grep -q "style.css?v=${h}" /srv/fieldwork/index.html
|