#!/bin/sh
set -eu

if [ "$#" -ne 1 ]; then
  echo "Usage: $0 who_need_help_e2e_RUN_ID" >&2
  exit 1
fi

project=$1

case "$project" in
  who_need_help_e2e_*) ;;
  *)
    echo "Refusing to stop a non-E2E Compose project: $project" >&2
    exit 1
    ;;
esac

ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)

docker compose \
  --project-name "$project" \
  --env-file "$ROOT/.env.e2e" \
  --file "$ROOT/compose.yaml" \
  --file "$ROOT/compose.e2e.yaml" \
  down --volumes --remove-orphans
