blob: d0ea73f208093c5f22881cb2937ea14acd0af909 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/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}"
log() {
printf '[aigw-debug] %s\n' "$*"
}
fail() {
printf '[aigw-debug] error: %s\n' "$*" >&2
exit 1
}
command -v docker >/dev/null 2>&1 || fail "docker is not installed"
docker info >/dev/null 2>&1 || fail "cannot access Docker; check that the daemon is running and your user belongs to the docker group"
if [[ ! -f "$env_file" ]]; then
command -v openssl >/dev/null 2>&1 || fail "openssl is required to generate local credentials"
credential_key="$(openssl rand -base64 32 | tr -d '\n')"
admin_token="aigw-admin-$(openssl rand -hex 24)"
umask 077
{
printf 'AIGW_CREDENTIAL_KEY=%s\n' "$credential_key"
printf 'AIGW_ADMIN_TOKEN=%s\n' "$admin_token"
} >"$env_file"
chmod 600 "$env_file"
log "created $env_file"
fi
for required_name in AIGW_CREDENTIAL_KEY AIGW_ADMIN_TOKEN; do
grep -q "^${required_name}=." "$env_file" || fail "$required_name is missing from $env_file"
done
compose=(docker compose --project-directory "$repo_dir")
if [[ -n "${AIGW_COMPOSE_PROJECT_NAME:-}" ]]; then
compose+=(--project-name "$AIGW_COMPOSE_PROJECT_NAME")
fi
compose+=(--env-file "$env_file")
cd "$repo_dir"
if [[ "${AIGW_DEBUG_SKIP_BUILD:-0}" == "1" ]]; then
log "starting all services without rebuilding the gateway image"
up_args=(up -d --no-build --remove-orphans --wait --wait-timeout 120)
else
log "building and starting all services"
up_args=(up -d --build --remove-orphans --wait --wait-timeout 120)
fi
if ! "${compose[@]}" "${up_args[@]}"; then
"${compose[@]}" ps >&2 || true
"${compose[@]}" logs --no-color --tail=120 aigw >&2 || true
fail "services did not become healthy"
fi
log "all services are ready"
printf '\nInference: http://127.0.0.1:8080/\n'
printf 'Admin UI: http://127.0.0.1:8081/admin/\n'
printf 'Health: http://127.0.0.1:9090/readyz\n'
printf 'Mailpit: http://127.0.0.1:8025/\n'
printf 'Secrets: %s (mode 0600)\n' "$env_file"
printf '\nLogs: docker compose --project-directory %q --env-file %q logs -f\n' "$repo_dir" "$env_file"
printf 'Stop: ./scripts/stop-debug.sh\n'
|