From 1e6149107d410c1b6b3c8d79e27a0cf27502c937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=90=D0=BD=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BF=D0=BE=D0=B2?= Date: Wed, 20 Aug 2025 15:49:17 +0300 Subject: [PATCH] refactor: move app.py and excluded_containers.json to app/ directory --- Dockerfile | 3 ++- app.py => app/app.py | 12 ++++++------ .../excluded_containers.json | 0 start.sh | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) rename app.py => app/app.py (98%) rename excluded_containers.json => app/excluded_containers.json (100%) diff --git a/Dockerfile b/Dockerfile index 6db1ff4..f98342a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ WORKDIR /app COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r requirements.txt -COPY app.py /app/app.py +COPY app/app.py /app/app.py +COPY app/excluded_containers.json /app/excluded_containers.json COPY ./app/templates /app/templates COPY ./app/static /app/static diff --git a/app.py b/app/app.py similarity index 98% rename from app.py rename to app/app.py index 6e8dbe7..2c67b1a 100644 --- a/app.py +++ b/app/app.py @@ -332,17 +332,17 @@ def load_excluded_containers() -> List[str]: Сайт: https://devops.org.ru """ try: - with open("excluded_containers.json", "r", encoding="utf-8") as f: + with open("app/excluded_containers.json", "r", encoding="utf-8") as f: data = json.load(f) return data.get("excluded_containers", []) except FileNotFoundError: - print("⚠️ Файл excluded_containers.json не найден, используем пустой список") + print("⚠️ Файл app/excluded_containers.json не найден, используем пустой список") return [] except json.JSONDecodeError as e: - print(f"❌ Ошибка парсинга excluded_containers.json: {e}") + print(f"❌ Ошибка парсинга app/excluded_containers.json: {e}") return [] except Exception as e: - print(f"❌ Ошибка загрузки excluded_containers.json: {e}") + print(f"❌ Ошибка загрузки app/excluded_containers.json: {e}") return [] def save_excluded_containers(containers: List[str]) -> bool: @@ -356,11 +356,11 @@ def save_excluded_containers(containers: List[str]) -> bool: "excluded_containers": containers, "description": "Список контейнеров, которые генерируют слишком много логов и исключаются из отображения" } - with open("excluded_containers.json", "w", encoding="utf-8") as f: + with open("app/excluded_containers.json", "w", encoding="utf-8") as f: json.dump(data, f, indent=2, ensure_ascii=False) return True except Exception as e: - print(f"❌ Ошибка сохранения excluded_containers.json: {e}") + print(f"❌ Ошибка сохранения app/excluded_containers.json: {e}") return False def get_all_projects() -> List[str]: diff --git a/excluded_containers.json b/app/excluded_containers.json similarity index 100% rename from excluded_containers.json rename to app/excluded_containers.json diff --git a/start.sh b/start.sh index 94a1b55..4210a17 100755 --- a/start.sh +++ b/start.sh @@ -20,7 +20,7 @@ if [ "$DEBUG_MODE" = "true" ]; then echo "Swagger UI: http://0.0.0.0:$LOGBOARD_PORT/docs" echo "ReDoc: http://0.0.0.0:$LOGBOARD_PORT/redoc" - exec uvicorn app:app \ + exec uvicorn app.app:app \ --host 0.0.0.0 \ --port $LOGBOARD_PORT \ --reload \ @@ -28,7 +28,7 @@ if [ "$DEBUG_MODE" = "true" ]; then else echo "Starting in PRODUCTION mode..." - exec uvicorn app:app \ + exec uvicorn app.app:app \ --host 0.0.0.0 \ --port $LOGBOARD_PORT \ --log-level info