diff --git a/.dockerignore b/.dockerignore index d429bfc..a7680c5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -25,4 +25,4 @@ README.md COOLIFY.md # Нужни за образа (НЕ игнорирай): -# Dockerfile, requirements-webapp.txt, webapp/, help_processor.py, help_codes.py, Bairaci.png +# Dockerfile, requirements-webapp.txt, VERSION, webapp/, help_processor.py, help_codes.py, Bairaci.png diff --git a/Dockerfile b/Dockerfile index bd2d162..00db835 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY requirements-webapp.txt /app/ RUN pip install --no-cache-dir -r requirements-webapp.txt +COPY VERSION /app/VERSION COPY webapp /app/webapp COPY help_processor.py /app/help_processor.py COPY help_codes.py /app/help_codes.py diff --git a/README.md b/README.md index 2610d93..4bb2dee 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,10 @@ Live: [https://rip.inex-project.net/?prefix=RIP](https://rip.inex-project.net/?p Нови файлове, които още не са в `.sln`, пак се виждат в Git Changes. При нужда ги добави като Solution Items или ползвай Open Folder. +### Сравнение с production (`/healthz`) + +След Push + Coolify redeploy сравни `git` от [https://rip.inex-project.net/healthz](https://rip.inex-project.net/healthz) с локалното: Solution Explorer → **scripts** → десен клик `show-version.bat` → **Open Containing Folder** → двоен клик (прозорецът чака Enter). Префиксът (`0.3.0`) е във **VERSION** (Solution Explorer → **deploy**). Production вижда SHA едва след commit + push + redeploy. + ### Качване на картинки на сървъра Локалният `help_processor.py` пише в `q:\RIP_Help_Source\Output\` (включително `images/` подпапка). За deploy: diff --git a/RIP_Help_system.sln b/RIP_Help_system.sln index 8b79a4b..53395b4 100644 --- a/RIP_Help_system.sln +++ b/RIP_Help_system.sln @@ -29,6 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E119 RIP_load.bat = RIP_load.bat RIP_load_force.bat = RIP_load_force.bat RIP_view.bat = RIP_view.bat + show-version.bat = show-version.bat view.bat = view.bat EndProjectSection EndProject @@ -42,6 +43,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "deploy", "deploy", "{BC30BA docker-compose.yml = docker-compose.yml Dockerfile = Dockerfile README.md = README.md + VERSION = VERSION EndProjectSection EndProject Global diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..0d91a54 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.3.0 diff --git a/show-version.bat b/show-version.bat new file mode 100644 index 0000000..511f64a --- /dev/null +++ b/show-version.bat @@ -0,0 +1,24 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion +chcp 65001 > nul +rem Същите ключове като GET /healthz: ok, version, git. +rem Префиксът е от VERSION; SHA е от git (не може да е в commit-натия файл). + +set "ROOT=%~dp0" +if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%" +cd /d "%ROOT%" + +set "APP_VERSION=0.3.0" +if exist "%ROOT%\VERSION" ( + set /p APP_VERSION=<"%ROOT%\VERSION" +) + +set "GIT_SHA=dev" +for /f "usebackq delims=" %%I in (`git rev-parse --short=7 HEAD 2^>nul`) do set "GIT_SHA=%%I" + +echo {"ok": true, "version": "%APP_VERSION%+!GIT_SHA!", "git": "!GIT_SHA!"} +echo. +echo Сравни "git" с https://rip.inex-project.net/healthz +echo Production вижда SHA едва след commit + push + Coolify redeploy. +echo. +pause diff --git a/webapp/main.py b/webapp/main.py index 5472b44..fdf3075 100644 --- a/webapp/main.py +++ b/webapp/main.py @@ -16,6 +16,8 @@ Env: OUTPUT_DIR — локален/mounted път към секциите (default: share) HOME_IMAGE — път към home картинка GIT_SHA / SOURCE_COMMIT / COMMIT_SHA — git SHA (Coolify / Docker build-arg) + +Версия: префиксът е файлът VERSION в корена на репото (същият като show-version.bat). """ from __future__ import annotations @@ -58,7 +60,6 @@ HOME_IMAGE = os.getenv("HOME_IMAGE") # absolute path or None _IMG_PLACEHOLDER_RE = re.compile(r"\[IMG:\s*([^\]]+?)\s*\]") BASE_DIR = Path(__file__).parent -APP_VERSION = "0.3.0" _NO_CACHE = {"Cache-Control": "no-store, no-cache, max-age=0"} @@ -69,6 +70,22 @@ def _short_id(value: str, n: int = 7) -> str: return value[:n] if len(value) > n else value +def _resolve_app_version() -> str: + """Prefix from repo-root VERSION (same file as show-version.bat).""" + for candidate in (BASE_DIR.parent / "VERSION", Path("/app/VERSION")): + try: + if candidate.is_file(): + text = candidate.read_text(encoding="utf-8").strip().splitlines()[0].strip() + if text: + return text + except OSError: + pass + return "0.3.0" + + +APP_VERSION = _resolve_app_version() + + def _resolve_git() -> str: """Git SHA / build id that changes on each image rebuild.