From 410e85b6656114429d4fe3e05010ae12e5d965fb Mon Sep 17 00:00:00 2001 From: sstent Date: Mon, 15 Dec 2025 08:21:58 -0800 Subject: [PATCH] fix(config): Improve Consul config loading and add version info - Fixes an issue where configuration from Consul was not being loaded correctly due to multiple base64 and encoding issues. - Adds robust decoding logic with fallbacks to handle different value formats from Consul. - Adds the Git commit SHA as a version identifier to the Docker image and application logs to improve debuggability. --- .github/workflows/container-build.yml | 2 ++ Dockerfile | 5 +++++ fitbitsync.py | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index b5cf104..0148f0c 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -51,6 +51,8 @@ jobs: tags: | ${{ steps.registry.outputs.url }}/${{ github.repository }}:latest ${{ steps.registry.outputs.url }}/${{ github.repository }}:${{ github.sha }} + build-args: | + COMMIT_SHA=${{ github.sha }} cache-from: type=registry,ref=${{ steps.registry.outputs.url }}/${{ github.repository }}:buildcache cache-to: type=registry,ref=${{ steps.registry.outputs.url }}/${{ github.repository }}:buildcache,mode=max #cache-from: type=gha diff --git a/Dockerfile b/Dockerfile index 6faf462..12aee70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,11 @@ FROM python:3.13-slim # Set the working directory in the container WORKDIR /app +# Accept the Git commit SHA as a build argument +ARG COMMIT_SHA +# Set the Git SHA as an environment variable +ENV GIT_SHA=${COMMIT_SHA} + # Copy the dependencies file to the working directory COPY requirements.txt . diff --git a/fitbitsync.py b/fitbitsync.py index 1cd85db..7475e31 100644 --- a/fitbitsync.py +++ b/fitbitsync.py @@ -1359,11 +1359,13 @@ class WeightSyncApp: def show_status(self): """Show application status""" try: + git_sha = os.getenv('GIT_SHA', 'Not set') read_only_mode = self.config.get('sync.read_only_mode', False) status_info = self.state.get_status_info() print("\nšŸ“Š Weight Sync Status") print("=" * 50) + print(f"Version (Git SHA): {git_sha}") print(f"Mode: {'Read-only (No Garmin uploads)' if read_only_mode else 'Full sync mode'}") print(f"Backend: {'Consul' if CONSUL_LIBRARY else 'Unknown'}") print(f"Fitbit Library: {'Available' if FITBIT_LIBRARY else 'Not Available'}") @@ -1419,6 +1421,10 @@ async def main(): """Main application entry point""" import sys + # Log the Git SHA if it exists + git_sha = os.getenv('GIT_SHA', 'Not set') + logger.info(f"Running version (Git SHA): {git_sha}") + app = WeightSyncApp() if len(sys.argv) > 1: