$ErrorActionPreference = "Stop"

if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
    Write-Warning "Docker CLI was not found in PATH. Nothing to stop."
    exit 0
}

$null = cmd /c "docker info >nul 2>nul"
$dockerReady = $LASTEXITCODE -eq 0

if (-not $dockerReady) {
    Write-Warning "Docker daemon is not reachable. Nothing to stop."
    exit 0
}

$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$composeFile = Join-Path $repoRoot "ops/observability/local/docker-compose.yml"

docker compose -f $composeFile down
