services:
  stability-agent:
    build: .
    container_name: stability-agent
    user: "1000:1000"
    group_add:
      - "999"
    restart: unless-stopped
    volumes:
      - /opt/homelab:/opt/homelab
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/run/tailscale/tailscaled.sock:/var/run/tailscale/tailscaled.sock:ro
    environment:
      - STABILITY_CHECK_INTERVAL=${STABILITY_CHECK_INTERVAL:-60}
      - DISK_THRESHOLD_PCT=${DISK_THRESHOLD_PCT:-90}
      - MQTT_HOST=${MQTT_HOST}
      - MQTT_PORT=${MQTT_PORT:-1883}
      - REDIS_HOST=${REDIS_HOST:-100.108.208.3}
      - REDIS_PORT=${REDIS_PORT:-6379}
      - REDIS_ENABLED=${REDIS_ENABLED:-true}
      - NODE_NAME=${NODE_NAME:-chelsty}
    healthcheck:
      test: ["CMD", "/bin/sh", "/app/healthcheck.sh"]
      interval: 1m
      timeout: 10s
      retries: 3

volumes:
  opt_homelab:
    external: true
    name: homelab_data # This might vary, but /opt/homelab mount is preferred as direct path.
