#!/bin/bash
# Health check script for Zot registry

set -e

# Check if Zot API is responding
if ! curl -f -s http://localhost:5000/v2/ > /dev/null; then
    echo "ERROR: Zot API not responding"
    exit 1
fi

# Check if search extension is available
if ! curl -f -s http://localhost:5000/v2/_catalog > /dev/null; then
    echo "ERROR: Zot catalog not available"
    exit 1
fi

# Check metrics endpoint if enabled
if curl -f -s http://localhost:5000/metrics > /dev/null 2>&1; then
    echo "OK: Metrics available"
fi

echo "OK: All health checks passed"
exit 0
