From 8d72f1f12f9a48b1643498e0b387ba1566bc11a7 Mon Sep 17 00:00:00 2001 From: SysAdmin Agent Date: Sat, 4 Apr 2026 17:06:44 +0000 Subject: [PATCH] Fix GrampsWeb production config: restart policy + sync to nginx sub_filter approach (STI-91) - compose.yml: add restart: unless-stopped to grampsweb (production resilience) - docker-compose.prod.yml: remove stale container-patching, align to nginx sub_filter approach (STI-98/102); update GRAMPSWEB_BASE_URL default to full URL Co-Authored-By: Claude Sonnet 4.6 --- compose.yml | 1 + deploy-production/docker-compose.prod.yml | 44 ++--------------------- 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/compose.yml b/compose.yml index d19119e..9a59b86 100644 --- a/compose.yml +++ b/compose.yml @@ -190,6 +190,7 @@ services: grampsweb: image: ghcr.io/gramps-project/grampsweb:latest + restart: unless-stopped ports: - "8090:5000" environment: diff --git a/deploy-production/docker-compose.prod.yml b/deploy-production/docker-compose.prod.yml index 32b6501..24b574e 100644 --- a/deploy-production/docker-compose.prod.yml +++ b/deploy-production/docker-compose.prod.yml @@ -123,56 +123,16 @@ services: - GRAMPSWEB_ADMIN_EMAIL=${GRAMPSWEB_ADMIN_EMAIL} - GRAMPSWEB_ADMIN_PASSWORD=${GRAMPSWEB_ADMIN_PASSWORD} - GRAMPSWEB_TREE=${GRAMPSWEB_TREE:-Stiftung} - - GRAMPSWEB_BASE_URL=${GRAMPSWEB_BASE_URL:-/} + - GRAMPSWEB_BASE_URL=${GRAMPSWEB_BASE_URL:-https://vhtv-stiftung.de/ahnenforschung} - GRAMPSWEB_CELERY_CONFIG__broker_url=redis://redis:6379/0 - GRAMPSWEB_CELERY_CONFIG__result_backend=redis://redis:6379/0 - GRAMPSWEB_RATELIMIT_STORAGE_URI=redis://redis:6379/1 - GRAMPSWEB_NEW_DB_BACKEND=sqlite - - GRAMPSWEB_SUBPATH=${GRAMPSWEB_SUBPATH:-/ahnenforschung} command: - sh - -c - | - if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then - SUBPATH="$$GRAMPSWEB_SUBPATH" - case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac - echo "[grampsweb] Patching static files for subpath $$SUBPATH ..." - find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do - if grep -q '' "$$f" 2>/dev/null; then - sed -i "s|||g" "$$f" - echo "[grampsweb] patched base href: $$f" - fi - done - for f in /app/static/*.js; do - if [ -f "$$f" ] && grep -q '/api/' "$$f" 2>/dev/null; then - sed -i "s|\"/api/|\"$${SUBPATH}api/|g" "$$f" - sed -i 's|`/api/|`'"$${SUBPATH}"'api/|g' "$$f" - sed -i "s|\"/lang/|\"$${SUBPATH}lang/|g" "$$f" - sed -i 's|`/lang/|`'"$${SUBPATH}"'lang/|g' "$$f" - sed -i "s|\"/fonts/|\"$${SUBPATH}fonts/|g" "$$f" - sed -i 's|`/fonts/|`'"$${SUBPATH}"'fonts/|g' "$$f" - sed -i "s|\"/assets/|\"$${SUBPATH}assets/|g" "$$f" - sed -i 's|`/assets/|`'"$${SUBPATH}"'assets/|g' "$$f" - sed -i "s|location\.href=\"/\"|location.href=\"$$SUBPATH\"|g" "$$f" - sed -i "s|document\.location\.href=\"/\"|document.location.href=\"$$SUBPATH\"|g" "$$f" - echo "[grampsweb] patched JS paths: $$f" - fi - done - if [ -f /app/static/sw.js ]; then - sed -i "s|createHandlerBoundToURL(\"/index.html\")|createHandlerBoundToURL(\"$${SUBPATH}index.html\")|g" /app/static/sw.js - SUBPATH_BS=$$(echo "$$SUBPATH" | sed "s|/|\\\\\\\\/|g") - sed -i "s|\\^\\\\/api|\\^$${SUBPATH_BS}api|g" /app/static/sw.js - echo "[grampsweb] patched sw.js navigation routes" - fi - find /app/static -name '*.css' 2>/dev/null | while read f; do - if grep -q '\.\./fonts/' "$$f" 2>/dev/null; then - sed -i "s|'../fonts/|'fonts/|g" "$$f" - sed -i "s|\"../fonts/|\"fonts/|g" "$$f" - echo "[grampsweb] patched CSS font paths: $$f" - fi - done - echo "[grampsweb] Done." - fi + # All subpath rewriting is handled by nginx sub_filter — no container patching needed. echo "[grampsweb] Ensuring admin user exists ..." python3 << 'PYEOF' 2>&1 | grep -v Gtk from gramps_webapi.app import create_app