21 lines
578 B
Bash
Executable File
21 lines
578 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
|
|
|
matches=0
|
|
target_container=
|
|
for container in $(docker compose --env-file .env ps -q api); do
|
|
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
|
|
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
|
matches=$((matches + 1))
|
|
target_container=$container
|
|
fi
|
|
done
|
|
|
|
if [ "$matches" -ne 1 ]; then
|
|
printf '%s\n' 'Could not resolve TARGET_INSTANCE_ID to exactly one API container.' >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker stop --time 2 "$target_container" >/dev/null
|