Changeset 0.14.0 (#67)
This commit is contained in:
@@ -39,6 +39,12 @@ fi
|
||||
# ── Read environment name ─────────────────
|
||||
ENVIRONMENT="${ENVIRONMENT:-production}"
|
||||
|
||||
# Compute build hash from frontend file contents (changes on every deploy)
|
||||
BUILD_HASH=$(find /usr/share/nginx/html/js -name '*.js' -exec md5sum {} + 2>/dev/null | sort | md5sum | cut -c1-8)
|
||||
if [ -z "${BUILD_HASH}" ]; then
|
||||
BUILD_HASH=$(date +%s | md5sum | cut -c1-8)
|
||||
fi
|
||||
|
||||
# ── Inject into index.html ──────────────────
|
||||
sed -i \
|
||||
-e "s|%%BASE_PATH%%|${BASE_PATH}|g" \
|
||||
@@ -48,12 +54,13 @@ sed -i \
|
||||
-e "s|%%BRANDING_JSON%%|${BRANDING_JSON}|g" \
|
||||
/usr/share/nginx/html/index.html
|
||||
|
||||
# Inject version into service worker
|
||||
# Inject version and build hash into service worker
|
||||
sed -i \
|
||||
-e "s|%%APP_VERSION%%|${APP_VERSION}|g" \
|
||||
-e "s|%%BUILD_HASH%%|${BUILD_HASH}|g" \
|
||||
/usr/share/nginx/html/sw.js
|
||||
|
||||
echo "✅ Frontend configured: BASE_PATH=${BASE_PATH:-/} VERSION=${APP_VERSION} ENV=${ENVIRONMENT}"
|
||||
echo "✅ Frontend configured: BASE_PATH=${BASE_PATH:-/} VERSION=${APP_VERSION} BUILD=${BUILD_HASH} ENV=${ENVIRONMENT}"
|
||||
|
||||
# ── Generate nginx config ───────────────────
|
||||
# If BASE_PATH is set, serve under that prefix with alias.
|
||||
@@ -77,6 +84,12 @@ server {
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Service worker must never be cached by the browser
|
||||
location = /sw.js {
|
||||
expires off;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# Branding assets — served from volume mount, 404s gracefully
|
||||
location /branding/ {
|
||||
alias /branding/;
|
||||
@@ -120,6 +133,13 @@ server {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Service worker must never be cached by the browser
|
||||
location = ${BASE_PATH}/sw.js {
|
||||
alias /usr/share/nginx/html/sw.js;
|
||||
expires off;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
}
|
||||
|
||||
# Branding assets — under BASE_PATH so Traefik routes them here
|
||||
|
||||
Reference in New Issue
Block a user