Skip to content

Commit a8645a0

Browse files
authored
Merge pull request #68 from gapitio/frontend-subpath
feat: add base URL for the frontend and backend of Alerta
2 parents d41d805 + c3096aa commit a8645a0

7 files changed

Lines changed: 21 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v3.2.2
2+
### Feat
3+
- add subpath/base url for frontend
4+
15
## v3.2.1
26
### Fix
37
- change status from wildcard to exact match in alert and history filter

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ENV UWSGI_LISTEN=100
2323
ENV UWSGI_BUFFER_SIZE=8192
2424
ENV UWSGI_MAX_WORKER_LIFETIME=30
2525
ENV UWSGI_WORKER_LIFETIME_DELTA=3
26+
ENV FRONTEND_BASE_URL=/
2627

2728
ENV HEARTBEAT_SEVERITY=major
2829

config/templates/app/alerta.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DEFAULT]
22
sslverify = no
33
output = presto
4-
endpoint = http://localhost:8080/api
4+
endpoint = http://localhost:8080{{ env.FRONTEND_BASE_URL }}api
55
timezone = Europe/London
66
{%- if env.API_KEY %}
77
key = {{ env.API_KEY }}

config/templates/app/nginx.conf.j2

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ http {
4646

4747
access_log /dev/stdout main;
4848

49-
location /api {
49+
location {{ env.FRONTEND_BASE_URL }}api {
5050
include /etc/nginx/uwsgi_params;
5151
uwsgi_pass backend;
5252

@@ -58,8 +58,9 @@ http {
5858

5959
root /web;
6060
index index.html;
61-
location / {
62-
try_files $uri $uri/ /index.html;
61+
62+
location {{ env.FRONTEND_BASE_URL }} {
63+
try_files $uri $uri/ {{ env.FRONTEND_BASE_URL }}index.html;
6364
}
6465
}
6566
}

config/templates/app/uwsgi.ini.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ log-route = info ^\D
44
chdir = /app
55
module = wsgi
66
manage-script-name = true
7-
mount = /api=wsgi:app
7+
mount = {{ env.FRONTEND_BASE_URL }}api=wsgi:app
88
master = true
99
processes = {{ env.UWSGI_PROCESSES }}
1010
listen = {{ env.UWSGI_LISTEN }}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
{"endpoint": "/api"}
1+
{
2+
"endpoint": "{{ env.FRONTEND_BASE_URL }}api",
3+
"base": "{{ env.FRONTEND_BASE_URL }}"
4+
}

docker-entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ JINJA2="import os, sys, jinja2; sys.stdout.write(jinja2.Template(sys.stdin.read(
44

55
ALERTA_CONF_FILE=${ALERTA_CONF_FILE:-/app/alerta.conf}
66
ALERTA_SVR_CONF_FILE=${ALERTA_SVR_CONF_FILE:-/app/alertad.conf}
7-
ALERTA_WEB_CONF_FILE=${ALERTA_WEB_CONF_FILE:-/web/config.json}
7+
ALERTA_WEB_CONF_FILE=/web${FRONTEND_BASE_URL}config.json
88
NGINX_CONF_FILE=/app/nginx.conf
99
UWSGI_CONF_FILE=/app/uwsgi.ini
1010
SUPERVISORD_CONF_FILE=/app/supervisord.conf
@@ -76,6 +76,11 @@ if [ ! -f "${UWSGI_CONF_FILE}" ]; then
7676
python3 -c "${JINJA2}" < ${UWSGI_CONF_FILE}.j2 >${UWSGI_CONF_FILE}
7777
fi
7878

79+
if [ ! -d "/web${FRONTEND_BASE_URL}" ]; then
80+
mkdir /web${FRONTEND_BASE_URL}
81+
mv /web/* /web${FRONTEND_BASE_URL} || :
82+
fi
83+
7984
# Generate web config, if not supplied.
8085
if [ ! -f "${ALERTA_WEB_CONF_FILE}" ]; then
8186
if [ $INIT_LOG = true ]; then echo "# Create web configuration file."; fi

0 commit comments

Comments
 (0)