summaryrefslogtreecommitdiff
path: root/scripts/stop-debug.sh
blob: 8976d2cb724c2716a7c82668acded58972dc5e4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash

set -euo pipefail

script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
repo_dir="$(cd -- "$script_dir/.." && pwd)"
env_file="${AIGW_DEBUG_ENV_FILE:-$repo_dir/.env.debug}"

command -v docker >/dev/null 2>&1 || {
  printf '[aigw-debug] error: docker is not installed\n' >&2
  exit 1
}

if [[ -f "$env_file" ]]; then
  compose=(docker compose --env-file "$env_file")
else
  export AIGW_CREDENTIAL_KEY=debug-stop-placeholder
  export AIGW_ADMIN_TOKEN=debug-stop-placeholder
  export AIGW_STRIPE_API_KEY=debug-stop-placeholder
  export AIGW_STRIPE_WEBHOOK_SECRET=debug-stop-placeholder
  compose=(docker compose)
fi

cd "$repo_dir"
printf '[aigw-debug] stopping services\n'
"${compose[@]}" down --remove-orphans
printf '[aigw-debug] stopped; PostgreSQL and Redis volumes were preserved\n'