diff --git a/Dockerfile b/Dockerfile index 2258331..18931b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,21 +57,24 @@ ENV TFW_TERMINADO_DIR="/tmp/terminado_server" 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 PYTHONPATH=${TFW_LIB_DIR} COPY nginx /etc/nginx -RUN chown -R ${AVATAO_USER}: /var/log/nginx /var/lib/nginx && \ +COPY lib ${TFW_LIB_DIR} +COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF} +COPY supervisor/components/ ${TFW_SUPERVISORD_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 && \ + 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 &&\ mv /data/dist ${TFW_FRONTEND_DIR} USER ${AVATAO_USER} WORKDIR /home/${AVATAO_USER} -COPY lib ${TFW_LIB_DIR} -COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF} -COPY src/app ${TFW_APP_DIR} -COPY src/event_handlers ${TFW_EVENT_HANDLERS_DIR} CMD . "$HOME/.pyenvrc" && exec supervisord --nodaemon diff --git a/supervisor/components/event_handlers.conf b/supervisor/components/event_handlers.conf new file mode 100644 index 0000000..887c1c6 --- /dev/null +++ b/supervisor/components/event_handlers.conf @@ -0,0 +1,3 @@ +[program:event_handler_main] +directory=%(ENV_TFW_EVENT_HANDLERS_DIR)s +command=env python event_handler_main.py diff --git a/supervisor/components/login.conf b/supervisor/components/login.conf new file mode 100644 index 0000000..443b1af --- /dev/null +++ b/supervisor/components/login.conf @@ -0,0 +1,4 @@ +[program:login] +directory=%(ENV_TFW_LOGIN_APP_DIR)s +command=env python server.py +autostart=false diff --git a/supervisor/components/terminado.conf b/supervisor/components/terminado.conf new file mode 100644 index 0000000..ccf7595 --- /dev/null +++ b/supervisor/components/terminado.conf @@ -0,0 +1,4 @@ +[program:terminado] +directory=%(ENV_TFW_TERMINADO_DIR)s +command=env python server.py +autostart=false diff --git a/supervisor/supervisord.conf b/supervisor/supervisord.conf index 441cbd7..72803d2 100644 --- a/supervisor/supervisord.conf +++ b/supervisor/supervisord.conf @@ -13,25 +13,14 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=http://127.0.0.1:%(ENV_TFW_SUPERVISOR_HTTP_PORT)s -[program:app] -directory=%(ENV_TFW_APP_DIR)s -command=env python app.py - -[program:event_handler_main] -directory=%(ENV_TFW_EVENT_HANDLERS_DIR)s -command=env python event_handler_main.py - -[program:login] -directory=%(ENV_TFW_LOGIN_APP_DIR)s -command=env python server.py -autostart=false - -[program:terminado] -directory=%(ENV_TFW_TERMINADO_DIR)s -command=env python server.py -autostart=false - [program:nginx] command=/usr/sbin/nginx -g 'daemon off;' autostart=true autorestart=true + +[program:app] +directory=%(ENV_TFW_APP_DIR)s +command=env python app.py + +[include] +files=%(ENV_TFW_SUPERVISORD_COMPONENTS)s/*.conf