From 4b14d042d7205b9d9f49ce09531d93b900a0d2da Mon Sep 17 00:00:00 2001 From: nocci Date: Sun, 4 May 2025 14:50:55 +0200 Subject: [PATCH] add possibility to set debug-mode in .env --- setup.sh | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 26810e7..25d77c6 100644 --- a/setup.sh +++ b/setup.sh @@ -154,6 +154,9 @@ APPRISE_URLS="" #APPRISE_URLS="pover://USER_KEY@APP_TOKEN #gotify://gotify.example.com/TOKEN #matrixs://TOKEN@matrix.org/!ROOM_ID" + +# Enable Debug (e.g. for VS Code) +DEBUGPY=0 EOL cd $PROJECT_DIR @@ -1974,14 +1977,28 @@ body { CSS_END -# 7. Directories and permissions +# 7. directories and permissions mkdir -p ../data chmod -R a+rwX ../data find ../data -type d -exec chmod 775 {} \; find ../data -type f -exec chmod 664 {} \; +# entrypoint.sh script +cat < entrypoint.sh +#!/bin/sh +if [ "$DEBUGPY" = "1" ]; then + echo "Start with debugpy..." + exec python -m debugpy --listen 0.0.0.0:5678 --wait-for-client app.py +else + echo "Start with gunicorn..." + exec gunicorn -b 0.0.0.0:5000 app:app +fi +SCRIPT_END -# Translate-Skript erstellen UND SOFORT AUSFÜHREN +chmod +x entrypoint.sh + + +# create translate.sh and run it cat <<'SCRIPT_END' > ../translate.sh set -e @@ -1994,7 +2011,7 @@ if ! command -v jq &>/dev/null; then echo "❌ jq is required. Install with: sudo apt-get install jq" exit 1 fi -echo "\n\033[1;32m✅ we are extracting translations from the templates.\033[0m" +echo -e "\n\033[1;32m✅ we are extracting translations from the templates.\033[0m" # 1. Lege JSON-Dateien an, falls sie fehlen for lang in "${LANGS[@]}"; do file="$TRANSLATION_DIR/$lang.json" @@ -2022,7 +2039,7 @@ for lang in "${LANGS[@]}"; do mv "$tmp" "$file" echo "Updated $file" done -echo "\n\033[1;32m✅ JSON translation files updated. Please enter your translations!\033[0m" +echo -e "\n\033[1;32m✅ JSON translation files updated. Please enter your translations!\033[0m" SCRIPT_END chmod +x ../translate.sh @@ -2054,6 +2071,8 @@ RUN mkdir -p /app/data && \ ENV TZ=${TZ} RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +COPY entrypoint.sh /app/entrypoint.sh +RUN chmod +x /app/entrypoint.sh WORKDIR /app COPY requirements.txt . @@ -2071,9 +2090,9 @@ RUN groupadd -g ${GID} appuser && \ USER appuser -EXPOSE 5000 +EXPOSE 5000 5678 +ENTRYPOINT ["/app/entrypoint.sh"] -CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"] DOCKER_END # 6. docker-compose.yml @@ -2098,7 +2117,7 @@ services: - ../.env:/app/.env user: "${UID:-1000}:${GID:-1000}" restart: unless-stopped - command: ["python", "-m", "debugpy", "--listen", "0.0.0.0:5678", "--wait-for-client", "app.py"] + command: ["/app/entrypoint.sh"] COMPOSE_END