From c21db6779b62f62e5159d2a74bf16d3cf5cd5fcd Mon Sep 17 00:00:00 2001 From: sbgap Date: Thu, 5 Mar 2026 14:46:24 +0100 Subject: [PATCH 1/5] feat: add environment variable for frontend base path --- CHANGELOG.md | 4 ++++ Dockerfile | 1 + config/templates/app/nginx.conf.j2 | 3 ++- config/templates/web/config.json.j2 | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8634b37e..ccb80f6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v3.2.2 +### Feat +- add subpath/base url for frontend + ## v3.2.1 ### Fix - change status from wildcard to exact match in alert and history filter diff --git a/Dockerfile b/Dockerfile index 24c77dcb..9dc6e1c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ ENV UWSGI_LISTEN=100 ENV UWSGI_BUFFER_SIZE=8192 ENV UWSGI_MAX_WORKER_LIFETIME=30 ENV UWSGI_WORKER_LIFETIME_DELTA=3 +ENV FRONTEND_BASE_URL=/ ENV HEARTBEAT_SEVERITY=major diff --git a/config/templates/app/nginx.conf.j2 b/config/templates/app/nginx.conf.j2 index 76772ab7..041cb6dc 100644 --- a/config/templates/app/nginx.conf.j2 +++ b/config/templates/app/nginx.conf.j2 @@ -58,7 +58,8 @@ http { root /web; index index.html; - location / { + + location {{ env.FRONTEND_BASE_URL }} { try_files $uri $uri/ /index.html; } } diff --git a/config/templates/web/config.json.j2 b/config/templates/web/config.json.j2 index 004ae8e0..316b1b2f 100644 --- a/config/templates/web/config.json.j2 +++ b/config/templates/web/config.json.j2 @@ -1 +1,4 @@ -{"endpoint": "/api"} +{ + "endpoint": "/api", + "base": "{{ env.FRONTEND_BASE_URL }}" +} From da99dd20e0cb0f98947a3458642cb202bf65c4f1 Mon Sep 17 00:00:00 2001 From: sbgap Date: Fri, 6 Mar 2026 16:21:18 +0100 Subject: [PATCH 2/5] fix: move frontend files to correct folder --- config/templates/app/nginx.conf.j2 | 2 +- docker-entrypoint.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/templates/app/nginx.conf.j2 b/config/templates/app/nginx.conf.j2 index 041cb6dc..fb45f2be 100644 --- a/config/templates/app/nginx.conf.j2 +++ b/config/templates/app/nginx.conf.j2 @@ -60,7 +60,7 @@ http { index index.html; location {{ env.FRONTEND_BASE_URL }} { - try_files $uri $uri/ /index.html; + try_files $uri $uri/ {{ env.FRONTEND_BASE_URL }}index.html; } } } diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5a188b39..3ffa5be7 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -82,6 +82,11 @@ if [ ! -f "${ALERTA_WEB_CONF_FILE}" ]; then python3 -c "${JINJA2}" < ${ALERTA_WEB_CONF_FILE}.j2 >${ALERTA_WEB_CONF_FILE} fi +if [ ! -f "/web${FRONTEND_BASE_URL}" ]; then + mkdir /web${FRONTEND_BASE_URL} + mv /web/* /web${FRONTEND_BASE_URL} || : +fi + if [ $INIT_LOG = true ]; then echo echo '# Checking versions.' From d7b560a4dbfde9afcdcec24e4e2a324b87c4ebe9 Mon Sep 17 00:00:00 2001 From: sbgap Date: Fri, 6 Mar 2026 16:21:52 +0100 Subject: [PATCH 3/5] feat: add frontend_base_url to backend --- config/templates/app/alerta.conf.j2 | 2 +- config/templates/app/nginx.conf.j2 | 2 +- config/templates/app/uwsgi.ini.j2 | 2 +- config/templates/web/config.json.j2 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/templates/app/alerta.conf.j2 b/config/templates/app/alerta.conf.j2 index 94a33d26..d4b5494e 100644 --- a/config/templates/app/alerta.conf.j2 +++ b/config/templates/app/alerta.conf.j2 @@ -1,7 +1,7 @@ [DEFAULT] sslverify = no output = presto -endpoint = http://localhost:8080/api +endpoint = http://localhost:8080{{ env.FRONTEND_BASE_URL }}api timezone = Europe/London {%- if env.API_KEY %} key = {{ env.API_KEY }} diff --git a/config/templates/app/nginx.conf.j2 b/config/templates/app/nginx.conf.j2 index fb45f2be..00bd6a65 100644 --- a/config/templates/app/nginx.conf.j2 +++ b/config/templates/app/nginx.conf.j2 @@ -46,7 +46,7 @@ http { access_log /dev/stdout main; - location /api { + location {{ env.FRONTEND_BASE_URL }}api { include /etc/nginx/uwsgi_params; uwsgi_pass backend; diff --git a/config/templates/app/uwsgi.ini.j2 b/config/templates/app/uwsgi.ini.j2 index e345b52c..2c9c11ed 100644 --- a/config/templates/app/uwsgi.ini.j2 +++ b/config/templates/app/uwsgi.ini.j2 @@ -4,7 +4,7 @@ log-route = info ^\D chdir = /app module = wsgi manage-script-name = true -mount = /api=wsgi:app +mount = {{ env.FRONTEND_BASE_URL }}api=wsgi:app master = true processes = {{ env.UWSGI_PROCESSES }} listen = {{ env.UWSGI_LISTEN }} diff --git a/config/templates/web/config.json.j2 b/config/templates/web/config.json.j2 index 316b1b2f..cc9cd328 100644 --- a/config/templates/web/config.json.j2 +++ b/config/templates/web/config.json.j2 @@ -1,4 +1,4 @@ { - "endpoint": "/api", + "endpoint": "{{ env.FRONTEND_BASE_URL }}api", "base": "{{ env.FRONTEND_BASE_URL }}" } From 408cdba2a0e7c942aa008de6481275640c92082e Mon Sep 17 00:00:00 2001 From: sbgap Date: Fri, 6 Mar 2026 16:54:26 +0100 Subject: [PATCH 4/5] fix: check for directory and not file for frontend files --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 3ffa5be7..8ec8e254 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -82,7 +82,7 @@ if [ ! -f "${ALERTA_WEB_CONF_FILE}" ]; then python3 -c "${JINJA2}" < ${ALERTA_WEB_CONF_FILE}.j2 >${ALERTA_WEB_CONF_FILE} fi -if [ ! -f "/web${FRONTEND_BASE_URL}" ]; then +if [ ! -d "/web${FRONTEND_BASE_URL}" ]; then mkdir /web${FRONTEND_BASE_URL} mv /web/* /web${FRONTEND_BASE_URL} || : fi From c3096aa544060854c6f996d67ef7d358b4595ba7 Mon Sep 17 00:00:00 2001 From: sbgap Date: Tue, 10 Mar 2026 08:51:36 +0100 Subject: [PATCH 5/5] fix: move files before checking for config in new location --- docker-entrypoint.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8ec8e254..2b9b56fe 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,7 +4,7 @@ JINJA2="import os, sys, jinja2; sys.stdout.write(jinja2.Template(sys.stdin.read( ALERTA_CONF_FILE=${ALERTA_CONF_FILE:-/app/alerta.conf} ALERTA_SVR_CONF_FILE=${ALERTA_SVR_CONF_FILE:-/app/alertad.conf} -ALERTA_WEB_CONF_FILE=${ALERTA_WEB_CONF_FILE:-/web/config.json} +ALERTA_WEB_CONF_FILE=/web${FRONTEND_BASE_URL}config.json NGINX_CONF_FILE=/app/nginx.conf UWSGI_CONF_FILE=/app/uwsgi.ini SUPERVISORD_CONF_FILE=/app/supervisord.conf @@ -76,17 +76,17 @@ if [ ! -f "${UWSGI_CONF_FILE}" ]; then python3 -c "${JINJA2}" < ${UWSGI_CONF_FILE}.j2 >${UWSGI_CONF_FILE} fi +if [ ! -d "/web${FRONTEND_BASE_URL}" ]; then + mkdir /web${FRONTEND_BASE_URL} + mv /web/* /web${FRONTEND_BASE_URL} || : +fi + # Generate web config, if not supplied. if [ ! -f "${ALERTA_WEB_CONF_FILE}" ]; then if [ $INIT_LOG = true ]; then echo "# Create web configuration file."; fi python3 -c "${JINJA2}" < ${ALERTA_WEB_CONF_FILE}.j2 >${ALERTA_WEB_CONF_FILE} fi -if [ ! -d "/web${FRONTEND_BASE_URL}" ]; then - mkdir /web${FRONTEND_BASE_URL} - mv /web/* /web${FRONTEND_BASE_URL} || : -fi - if [ $INIT_LOG = true ]; then echo echo '# Checking versions.'