From ad34ebff89cb50803dd95b20254898be57f03842 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Mar 2023 10:49:26 +0100 Subject: [PATCH] :whale: Add backend and exporter uri env vars to frontend docker image --- CHANGES.md | 6 ++++++ docker/images/Dockerfile.frontend | 2 +- docker/images/files/nginx-entrypoint.sh | 15 +++++++++++---- docker/images/files/nginx.conf | 12 ++++-------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a2791c2bc..0d4e73b65 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,5 @@ # CHANGELOG + ## 1.17.3 ### :bug: Bugs fixed @@ -9,6 +10,11 @@ - Fix search field has implemented shared styles for "close icon" and "search icon" [Taiga #4927](https://tree.taiga.io/project/penpot/issue/4927) - Fix Handling correctly slashes "/" in emails [Taiga #4906](https://tree.taiga.io/project/penpot/issue/4906) - Fix Change text color from selected colors [Taiga #4933](https://tree.taiga.io/project/penpot/issue/4933) + +### :sparkles: Enhancements + +- Adds environment variables for specifying the export and backend URI for the frontend docker image, thanks to @Supernova3339 for the initial PR and suggestion [Github #2984](https://github.com/penpot/penpot/issues/2984) + ## 1.17.2 ### :bug: Bugs fixed diff --git a/docker/images/Dockerfile.frontend b/docker/images/Dockerfile.frontend index 84b2493dc..af5101b29 100644 --- a/docker/images/Dockerfile.frontend +++ b/docker/images/Dockerfile.frontend @@ -8,7 +8,7 @@ RUN set -ex; \ ADD ./bundle-frontend/ /var/www/app/ ADD ./files/config.js /var/www/app/js/config.js -ADD ./files/nginx.conf /etc/nginx/nginx.conf +ADD ./files/nginx.conf /etc/nginx/nginx.conf.template ADD ./files/nginx-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] diff --git a/docker/images/files/nginx-entrypoint.sh b/docker/images/files/nginx-entrypoint.sh index 1e349e586..d8fc93567 100644 --- a/docker/images/files/nginx-entrypoint.sh +++ b/docker/images/files/nginx-entrypoint.sh @@ -1,9 +1,5 @@ #!/usr/bin/env bash -log() { - echo "[$(date +%Y-%m-%dT%H:%M:%S%:z)] $*" -} - ######################################### ## App Frontend config ######################################### @@ -17,4 +13,15 @@ update_flags() { } update_flags /var/www/app/js/config.js + + +######################################### +## Nginx Config +######################################### + +export PENPOT_BACKEND_URI=${PENPOT_BACKEND_URI:-http://penpot-backend:6060}; +export PENPOT_EXPORTER_URI=${PENPOT_EXPORTER_URI:-http://penpot-exporter}; + +envsubst "\$PENPOT_BACKEND_URI,\$PENPOT_EXPORTER_URI" < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf + exec "$@"; diff --git a/docker/images/files/nginx.conf b/docker/images/files/nginx.conf index a43f3bf66..34b01a2ef 100644 --- a/docker/images/files/nginx.conf +++ b/docker/images/files/nginx.conf @@ -82,7 +82,7 @@ http { } location /assets { - proxy_pass http://penpot-backend:6060/assets; + proxy_pass $PENPOT_BACKEND_URI/assets; recursive_error_pages on; proxy_intercept_errors on; error_page 301 302 307 = @handle_redirect; @@ -95,21 +95,17 @@ http { } location /api/export { - proxy_pass http://penpot-exporter:6061; + proxy_pass $PENPOT_EXPORTER_URI; } location /api { - proxy_pass http://penpot-backend:6060/api; + proxy_pass $PENPOT_BACKEND_URI/api; } - # location /admin { - # proxy_pass http://penpot-admin:6065/admin; - # } - location /ws/notifications { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; - proxy_pass http://penpot-backend:6060/ws/notifications; + proxy_pass $PENPOT_BACKEND_URI/ws/notifications; } location / {