diff --git a/Dockerfile b/Dockerfile index 7319eac..49d412e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,22 @@ RUN apt-get update \ COPY backend/ ./backend/ COPY frontend/ ./frontend/ +# Generate VERSION file from git (fallback for version.py when .git is not available) +COPY .git/HEAD .git/refs/ /tmp/git-refs/ +RUN cd /tmp/git-refs && \ + if [ -f HEAD ]; then \ + REF=$(cat HEAD | awk '{print $2}'); \ + if [ -f "$REF" ]; then \ + HASH=$(cat "$REF" | head -c 8); \ + echo "1.8.0-0-g${HASH}" > /app/backend/VERSION; \ + else \ + echo "1.8.0-dev" > /app/backend/VERSION; \ + fi; \ + else \ + echo "1.8.0-dev" > /app/backend/VERSION; \ + fi && \ + rm -rf /tmp/git-refs + # Create non-root user for security + data directory for auth persistence # Using explicit UID/GID 1000 to match common host user and docker-compose settings RUN groupadd -g 1000 obsigate && useradd -u 1000 -g obsigate -d /app -s /sbin/nologin obsigate \ diff --git a/backend/version.py b/backend/version.py index eddf40d..0fcfc67 100644 --- a/backend/version.py +++ b/backend/version.py @@ -37,8 +37,8 @@ def get_version() -> str: except (FileNotFoundError, subprocess.TimeoutExpired, OSError): pass - # Fallback: try reading from a VERSION file - version_file = _ROOT / "VERSION" + # Fallback: try reading from a VERSION file next to this module + version_file = Path(__file__).parent / "VERSION" if version_file.exists(): return version_file.read_text().strip()