From c20ff3a2a13bda61b55b0e9b981ac1d68c409ab3 Mon Sep 17 00:00:00 2001 From: DrunkBatya Date: Wed, 24 Jul 2024 15:27:34 +0000 Subject: [PATCH] Change structure --- Dockerfile | 7 ++++--- supervisord.conf => configs/supervisord.conf | 0 scripts/entrypoint.sh | 9 +++++++++ template_configs.py => scripts/template_configs.py | 0 templates/nginx.conf.j2 | 11 ++++++++++- 5 files changed, 23 insertions(+), 4 deletions(-) rename supervisord.conf => configs/supervisord.conf (100%) create mode 100755 scripts/entrypoint.sh rename template_configs.py => scripts/template_configs.py (100%) diff --git a/Dockerfile b/Dockerfile index 175fe19..2b97c98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt update && apt -y install nginx # Supervisor RUN DEBIAN_FRONTEND=noninteractive apt update && apt -y install supervisor RUN mkdir -p /var/log/supervisor -ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf +ADD configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Main RUN DEBIAN_FRONTEND=noninteractive apt update && apt -y install python3-pip @@ -27,5 +27,6 @@ RUN mkdir -p /etc/app ADD requirements.txt /usr/bin/app/ RUN python3 -m pip install -r /usr/bin/app/requirements.txt ADD templates /usr/bin/app/templates -ADD template_configs.py /usr/bin/app/template_configs.py -CMD python3 /usr/bin/app/template_configs.py && /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf +ADD scripts/template_configs.py /usr/bin/app/template_configs.py +ADD scripts/entrypoint.sh /usr/bin/app/entrypoint.sh +CMD ["/usr/bin/app/entrypoint.sh"] diff --git a/supervisord.conf b/configs/supervisord.conf similarity index 100% rename from supervisord.conf rename to configs/supervisord.conf diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100755 index 0000000..81f0f78 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail; # bash unofficial strict mode + +# template configs +python3 /usr/bin/app/template_configs.py + +# run supervisor +/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf; diff --git a/template_configs.py b/scripts/template_configs.py similarity index 100% rename from template_configs.py rename to scripts/template_configs.py diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index c6ec935..db05c14 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -14,6 +14,7 @@ http { access_log /dev/stdout main; sendfile on; keepalive_timeout 65; + {% for user in users %} server { listen 80; @@ -22,6 +23,8 @@ http { return 204; } } + {% endfor %} + server { listen 80 default_server; server_name _; @@ -29,5 +32,11 @@ http { return 444; } } - {% endfor %} + server { + listen 80; + server_name {{ hostname_base }}; + location / { + return 444; + } + } }