diff --git a/Dockerfile b/Dockerfile index 18931b4..f8c4411 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,20 +58,24 @@ ENV TFW_TERMINADO_WD="/home/${AVATAO_USER}" ENV TFW_LIB_DIR="/usr/local/lib/" ENV TFW_SUPERVISORD_CONF="/etc/supervisor/supervisord.conf" ENV TFW_SUPERVISORD_COMPONENTS="/etc/supervisor/conf" +ENV TFW_NGINX_CONF="/etc/nginx/sites-enabled/default" +ENV TFW_NGINX_COMPONENTS="/etc/nginx/components" ENV PYTHONPATH=${TFW_LIB_DIR} -COPY nginx /etc/nginx COPY lib ${TFW_LIB_DIR} COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF} COPY supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS} +COPY nginx/nginx.conf ${TFW_NGINX_CONF} +COPY nginx/components/ ${TFW_NGINX_COMPONENTS} COPY src/app ${TFW_APP_DIR} COPY src/event_handlers ${TFW_EVENT_HANDLERS_DIR} RUN chown -R ${AVATAO_USER}: /var/log/nginx /var/lib/nginx &&\ # nginx runs as a regular user, and can't write to /run sed -i 's#pid /run/nginx.pid;#pid /tmp/nginx.pid;#g' /etc/nginx/nginx.conf &&\ - envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" \ - < /etc/nginx/sites-available/default > /etc/nginx/sites-available/default &&\ + for f in "${TFW_NGINX_CONF}" ${TFW_NGINX_COMPONENTS}/*.conf; do \ + envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" < $f > $f ;\ + done &&\ mv /data/dist ${TFW_FRONTEND_DIR} USER ${AVATAO_USER} diff --git a/nginx/components/login.conf b/nginx/components/login.conf new file mode 100644 index 0000000..f8b1367 --- /dev/null +++ b/nginx/components/login.conf @@ -0,0 +1,3 @@ +location = /login { + proxy_pass http://127.0.0.1:${TFW_LOGIN_APP_PORT}; + } diff --git a/nginx/components/terminal.conf b/nginx/components/terminal.conf new file mode 100644 index 0000000..1d906a0 --- /dev/null +++ b/nginx/components/terminal.conf @@ -0,0 +1,6 @@ +location = /terminal { + proxy_pass http://127.0.0.1:${TFW_TERMINADO_PORT}; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } diff --git a/nginx/sites-available/default b/nginx/nginx.conf similarity index 59% rename from nginx/sites-available/default rename to nginx/nginx.conf index 409c749..ea60388 100644 --- a/nginx/sites-available/default +++ b/nginx/nginx.conf @@ -12,16 +12,7 @@ server { proxy_set_header Connection "Upgrade"; } - location = /terminal { - proxy_pass http://127.0.0.1:${TFW_TERMINADO_PORT}; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - - location = /login { - proxy_pass http://127.0.0.1:${TFW_LOGIN_APP_PORT}; - } + include ${TFW_NGINX_COMPONENTS}/*.conf; location / { root ${TFW_FRONTEND_DIR};