diff --git a/Dockerfile b/Dockerfile index 4005e58..2b7a6cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,8 +32,18 @@ RUN bun run build # Serve with NGINX FROM nginx:latest + +# control if the old js bundle from the cached index.html should be symlinked to the newest +# this is a workaround to prevent white page after bad caching rule on nginx +ARG USE_OLD_CACHED_HTML_WORKAROND_FIX=true +ARG OLD_JS_BUNDLE_HASH=jmByhSew + COPY --from=build /app/dist /usr/share/nginx/html -RUN rm /etc/nginx/conf.d/default.conf +RUN rm /etc/nginx/conf.d/default.conf && \ + if [ "$USE_OLD_CACHED_HTML_WORKAROND_FIX" = "true" ]; then \ + ln -sf /usr/share/nginx/html/assets/index-*.js /usr/share/nginx/html/assets/index-${OLD_JS_BUNDLE_HASH}.js; \ + fi + COPY nginx/nginx.conf /etc/nginx/conf.d COPY --from=build --chmod=777 --link /app/entrypoint.sh . diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f2bf565..d5b1156 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -17,6 +17,13 @@ server { access_log off; } + # Make sure the index.html isnt cached so we dont break the SPA on + # udpated js / css dists + location ~* \.html$ { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + expires -1; + } + # Handle all other requests by redirecting to index.html location / { try_files $uri /index.html;