services:
  garminsync:
    build: .
    container_name: garminsync
    ports:
      - "8888:8888"
    env_file:
      - .env
    volumes:
      - ./data:/data
      - ./internal/web/templates:/app/internal/web/templates
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    depends_on:
      garmin-api:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8888/health"]
      interval: 30s
      timeout: 30s
      retries: 3
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  garmin-api:
    build: ./garmin-api-wrapper
    container_name: garmin-api
    env_file:
      - .env
    ports:
      - "8081:8081"
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8081/health | grep -q 'authenticated' || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s
