fix(config): Improve Consul config loading and add version info
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 3m4s

- 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.
This commit is contained in:
2025-12-15 08:21:58 -08:00
parent 190371b099
commit 410e85b665
3 changed files with 13 additions and 0 deletions

View File

@@ -51,6 +51,8 @@ jobs:
tags: | tags: |
${{ steps.registry.outputs.url }}/${{ github.repository }}:latest ${{ steps.registry.outputs.url }}/${{ github.repository }}:latest
${{ steps.registry.outputs.url }}/${{ github.repository }}:${{ github.sha }} ${{ 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-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-to: type=registry,ref=${{ steps.registry.outputs.url }}/${{ github.repository }}:buildcache,mode=max
#cache-from: type=gha #cache-from: type=gha

View File

@@ -4,6 +4,11 @@ FROM python:3.13-slim
# Set the working directory in the container # Set the working directory in the container
WORKDIR /app 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 the dependencies file to the working directory
COPY requirements.txt . COPY requirements.txt .

View File

@@ -1359,11 +1359,13 @@ class WeightSyncApp:
def show_status(self): def show_status(self):
"""Show application status""" """Show application status"""
try: try:
git_sha = os.getenv('GIT_SHA', 'Not set')
read_only_mode = self.config.get('sync.read_only_mode', False) read_only_mode = self.config.get('sync.read_only_mode', False)
status_info = self.state.get_status_info() status_info = self.state.get_status_info()
print("\n📊 Weight Sync Status") print("\n📊 Weight Sync Status")
print("=" * 50) 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"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"Backend: {'Consul' if CONSUL_LIBRARY else 'Unknown'}")
print(f"Fitbit Library: {'Available' if FITBIT_LIBRARY else 'Not Available'}") print(f"Fitbit Library: {'Available' if FITBIT_LIBRARY else 'Not Available'}")
@@ -1419,6 +1421,10 @@ async def main():
"""Main application entry point""" """Main application entry point"""
import sys 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() app = WeightSyncApp()
if len(sys.argv) > 1: if len(sys.argv) > 1: