#!/bin/bash
# Healthcheck for narty27 (nginx:alpine serving a single self-contained viz.html)

# Container must be running
if ! docker ps --filter "name=narty27" --filter "status=running" | grep -qw "narty27"; then
    echo "[FAIL] narty27 container is not running"
    exit 1
fi

# Both copies must answer: viz.html is the canonical name, index.html makes the
# bare root work. An empty volume means the content was never loaded — see README.
for path in viz.html ""; do
    if ! curl -sf -o /dev/null "http://127.0.0.1:8240/${path}"; then
        echo "[FAIL] narty27 is not serving /${path} on 127.0.0.1:8240 (content loaded?)"
        exit 1
    fi
done

echo "[OK] narty27 is healthy"
exit 0
