#!/bin/sh set -eu : "${TARGET_INSTANCE_ID:?test provides target API instance alias}" cd "$(dirname "$0")/.." target="" for id in $(docker compose --env-file .env ps -q api); do hostname=$(docker inspect -f '{{.Config.Hostname}}' "$id") if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then target="$id" break fi done if [ -z "$target" ]; then echo "no running API replica has instance id $TARGET_INSTANCE_ID" >&2 exit 2 fi docker stop --time 5 "$target" >/dev/null