Fix GrampsWeb subpath: patch <base href> at container startup (STI-93)
The GrampsWeb SPA has <base href="/"> hardcoded at build time, causing assets to load from / instead of /ahnenforschung/ when behind a reverse proxy. Instead of relying on nginx sub_filter (which may not be available), patch the HTML at container startup via GRAMPSWEB_SUBPATH env var. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
17
compose.yml
17
compose.yml
@@ -202,6 +202,23 @@ services:
|
|||||||
- GRAMPSWEB_CELERY_CONFIG__result_backend=redis://redis:6379/0
|
- GRAMPSWEB_CELERY_CONFIG__result_backend=redis://redis:6379/0
|
||||||
- GRAMPSWEB_RATELIMIT_STORAGE_URI=redis://redis:6379/1
|
- GRAMPSWEB_RATELIMIT_STORAGE_URI=redis://redis:6379/1
|
||||||
- GRAMPSWEB_NEW_DB_BACKEND=sqlite
|
- GRAMPSWEB_NEW_DB_BACKEND=sqlite
|
||||||
|
- GRAMPSWEB_SUBPATH=${GRAMPSWEB_SUBPATH:-/ahnenforschung}
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
|
||||||
|
SUBPATH="$$GRAMPSWEB_SUBPATH"
|
||||||
|
# Ensure trailing slash for base href
|
||||||
|
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
|
||||||
|
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" \
|
||||||
|
/app/src/gramps_webapi/static/index.html \
|
||||||
|
/app/static/index.html 2>/dev/null || true
|
||||||
|
echo "Patched <base href> to $$SUBPATH"
|
||||||
|
fi
|
||||||
|
exec gunicorn -w $${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 \
|
||||||
|
gramps_webapi.wsgi:app --timeout $${GUNICORN_TIMEOUT:-120} \
|
||||||
|
--limit-request-line 8190
|
||||||
volumes:
|
volumes:
|
||||||
- gramps_data:/app/data
|
- gramps_data:/app/data
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -128,6 +128,22 @@ services:
|
|||||||
- GRAMPSWEB_CELERY_CONFIG__result_backend=redis://redis:6379/0
|
- GRAMPSWEB_CELERY_CONFIG__result_backend=redis://redis:6379/0
|
||||||
- GRAMPSWEB_RATELIMIT_STORAGE_URI=redis://redis:6379/1
|
- GRAMPSWEB_RATELIMIT_STORAGE_URI=redis://redis:6379/1
|
||||||
- GRAMPSWEB_NEW_DB_BACKEND=sqlite
|
- 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
|
||||||
|
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" \
|
||||||
|
/app/src/gramps_webapi/static/index.html \
|
||||||
|
/app/static/index.html 2>/dev/null || true
|
||||||
|
echo "Patched <base href> to $$SUBPATH"
|
||||||
|
fi
|
||||||
|
exec gunicorn -w $${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 \
|
||||||
|
gramps_webapi.wsgi:app --timeout $${GUNICORN_TIMEOUT:-120} \
|
||||||
|
--limit-request-line 8190
|
||||||
volumes:
|
volumes:
|
||||||
- gramps_data:/app/data
|
- gramps_data:/app/data
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user