diff --git a/Dockerfile b/Dockerfile index b7029d5..9029287 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,17 +2,14 @@ FROM python:3.11-slim WORKDIR /app -# Install dependencies +RUN apt-get update && apt-get install -y git + +RUN git clone https://git.marlow.quest/ash/Garmin-API.git + COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# Copy app -COPY app.py . -COPY logo.bin . - -# Expose port EXPOSE 5000 -# Run app RUN pip install gunicorn CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"] diff --git a/app.py b/app.py index ebff9da..1c1fd9f 100644 --- a/app.py +++ b/app.py @@ -12,6 +12,7 @@ PASSWORD = os.getenv("GARMIN_PASSWORD") START_DATE = datetime.date.fromisoformat(os.getenv("START_DATE", "2026-01-01")) GOAL_KM = float(os.getenv("GOAL_KM", "80")) ALLOWED_TYPES = os.getenv("ALLOWED_TYPES", "running,treadmill_running").split(",") +TEST_MODE = os.getenv("TEST_MODE", "false").lower() == "true" # Check if TEST_MODE is enabled CACHE_TTL = int(os.getenv("CACHE_TTL", "300")) # seconds (default 5 mins) @@ -45,6 +46,11 @@ def get_garmin_data(): now = time.time() + # --- Return test data if in test mode --- + if TEST_MODE: + print("⚡ Test mode enabled, returning hardcoded data") + return {"total_km": 70, "goal_km": 100, "percent": 12.6, "status": "success"} + # --- RETURN CACHED DATA --- if cached_data and (now - last_fetch_time < CACHE_TTL): print("⚡ Returning cached data") @@ -136,4 +142,4 @@ def get_image(): if __name__ == '__main__': - app.run(host='0.0.0.0', port=5000) + app.run(host='0.0.0.0', port=5000) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 534992c..79fc2e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,11 @@ services: garmin-api: - build: . - container_name: garmin + build: + context: . + dockerfile: Dockerfile + container_name: garmin-api ports: - "5000:5000" env_file: - .env - restart: unless-stopped + restart: unless-stopped \ No newline at end of file