From 6923ce9a3aad124a84a8d89bc0a11f58f2d405e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sondre=20Gr=C3=B8n=C3=A5s?= <44143748+sondregronas@users.noreply.github.com> Date: Sat, 26 Aug 2023 23:43:04 +0200 Subject: [PATCH] Dedicated entrypoint --- Dockerfile | 13 +------------ entrypoint.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index ead605c..38b22c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,18 +47,7 @@ RUN echo \ pip install -r requirements.txt && \ cp -r /FeideUtstyrbase/BookingSystem/* /app" > /usr/local/bin/auto-update.sh -# Entrypoint (Update / run) -RUN echo \ - "if [ \"\$AUTO_UPDATE\" = \"True\" ]; then \ - echo \"Auto update enabled\" && \ - sh /usr/local/bin/auto-update.sh; \ - else \ - echo \"Auto update disabled (AUTO_UPDATE not True)\"; \ - fi && \ - if [ -d \"/overrides\" ]; then \ - cp -r /overrides/* /app; \ - fi && \ - gunicorn -b 0.0.0.0:5000 app:app" > /usr/local/bin/entrypoint.sh +COPY entrypoint.sh /usr/local/bin/entrypoint.sh EXPOSE 5000 WORKDIR /app diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..8d3ace3 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +if [ "$AUTO_UPDATE" = "True" ]; then + echo "Auto update enabled" + sh /usr/local/bin/auto-update.sh; +else + echo "Auto update disabled (AUTO_UPDATE not True)"; +fi + +if [ -d "/overrides" ]; then + cp -r /overrides/* /app; +fi + +shutdown() { + kill -TERM $PID && wait $PID +} + +trap "shutdown" TERM + +gunicorn --bind 0.0.0.0:5000 app:app & +PID=$! +wait $PID