From deeea48b2040308346113e6371b784129feaaea8 Mon Sep 17 00:00:00 2001 From: Karl Date: Wed, 9 Jul 2025 10:59:28 +0100 Subject: [PATCH] add version and fix autocomplete --- .gitea/workflows/docker-publish.yml | 4 ++-- app.py | 11 +++++++++++ dockerfile | 9 ++++++--- templates/home.html | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/docker-publish.yml b/.gitea/workflows/docker-publish.yml index c0191e1..8f90a8e 100644 --- a/.gitea/workflows/docker-publish.yml +++ b/.gitea/workflows/docker-publish.yml @@ -23,8 +23,6 @@ jobs: tags: | type=raw,value=latest,enable={{is_default_branch}} type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -43,3 +41,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} diff --git a/app.py b/app.py index 09282f0..523cde6 100644 --- a/app.py +++ b/app.py @@ -31,6 +31,17 @@ app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Adjust for cross-site requests app.config['PERMANENT_SESSION_LIFETIME'] = 60 * 60 * 24 * 365 # 1 year in seconds cache.clear() # Clears all cache entries +def get_version(): + try: + with open('VERSION', 'r') as f: + return f.read().strip() + except FileNotFoundError: + return 'dev' + +@app.context_processor +def inject_version(): + return dict(version=get_version()) + @app.before_request def make_session_permanent(): session.permanent = True diff --git a/dockerfile b/dockerfile index 2daab93..f5776e6 100644 --- a/dockerfile +++ b/dockerfile @@ -1,13 +1,13 @@ -FROM python:3.11-slim +FROM python:3.11-slim-bookworm -# Install system dependencies required by PaddleOCR and OpenCV -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install -y --no-install-recommends \ libglib2.0-0 \ libsm6 \ libxrender1 \ libxext6 \ libgomp1 \ libgl1 \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* WORKDIR /app @@ -17,6 +17,9 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . +ARG VERSION +RUN echo $VERSION > VERSION + EXPOSE 8089 CMD ["python", "app.py"] diff --git a/templates/home.html b/templates/home.html index 223d590..1bcbe69 100644 --- a/templates/home.html +++ b/templates/home.html @@ -83,7 +83,7 @@