summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/start-debug.sh31
-rwxr-xr-xscripts/stop-debug.sh8
2 files changed, 34 insertions, 5 deletions
diff --git a/scripts/start-debug.sh b/scripts/start-debug.sh
index 698ae68..7a22a89 100755
--- a/scripts/start-debug.sh
+++ b/scripts/start-debug.sh
@@ -22,14 +22,32 @@ 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)"
+ postgres_password="$(openssl rand -hex 24)"
umask 077
{
- printf 'AIGW_DATABASE_URL=postgres://aigw:aigw@127.0.0.1:5432/aigw?sslmode=disable\n'
+ printf 'AIGW_SERVER_ADDRESS=:8080\n'
+ printf 'AIGW_POSTGRES_USER=aigw\n'
+ printf 'AIGW_POSTGRES_PASSWORD=%s\n' "$postgres_password"
+ printf 'AIGW_POSTGRES_DB=aigw\n'
+ printf 'AIGW_DATABASE_URL=postgres://aigw:%s@127.0.0.1:5432/aigw?sslmode=disable\n' "$postgres_password"
+ printf 'AIGW_DATABASE_URL_DOCKER=postgres://aigw:%s@postgres:5432/aigw?sslmode=disable\n' "$postgres_password"
printf 'AIGW_REDIS_URL=redis://127.0.0.1:6379/0\n'
+ printf 'AIGW_REDIS_URL_DOCKER=redis://redis:6379/0\n'
printf 'AIGW_CREDENTIAL_KEY=%s\n' "$credential_key"
printf 'AIGW_ADMIN_TOKEN=%s\n' "$admin_token"
+ printf 'AIGW_PUBLIC_URL=http://localhost:8080/admin/\n'
+ printf 'AIGW_WEBAUTHN_RP_ID=localhost\n'
+ printf 'AIGW_WEBAUTHN_ORIGINS=http://localhost:8080\n'
+ printf 'AIGW_SMTP_FROM_ADDRESS=no-reply@aigw.local\n'
+ printf 'AIGW_SMTP_ADDRESS=127.0.0.1:1025\n'
+ printf 'AIGW_SMTP_ADDRESS_DOCKER=mailpit:1025\n'
+ printf 'AIGW_SMTP_USERNAME=\n'
+ printf 'AIGW_SMTP_PASSWORD=\n'
printf 'AIGW_STRIPE_API_KEY=rk_test_replace_me\n'
+ printf 'AIGW_STRIPE_CLI_API_KEY=rk_test_replace_me\n'
printf 'AIGW_STRIPE_WEBHOOK_SECRET=whsec_replace_me\n'
+ printf 'AIGW_STRIPE_SUCCESS_URL=http://localhost:8080/admin/?topup=success\n'
+ printf 'AIGW_STRIPE_CANCEL_URL=http://localhost:8080/admin/?topup=cancel\n'
} >"$env_file"
chmod 600 "$env_file"
log "created $env_file"
@@ -37,6 +55,9 @@ fi
admin_token="$(sed -n 's/^AIGW_ADMIN_TOKEN=//p' "$env_file" | head -n 1)"
[[ -n "$admin_token" ]] || fail "AIGW_ADMIN_TOKEN is missing from $env_file"
+for required_name in AIGW_SERVER_ADDRESS AIGW_POSTGRES_USER AIGW_POSTGRES_PASSWORD AIGW_POSTGRES_DB AIGW_DATABASE_URL_DOCKER AIGW_CREDENTIAL_KEY AIGW_PUBLIC_URL AIGW_WEBAUTHN_RP_ID AIGW_WEBAUTHN_ORIGINS AIGW_SMTP_FROM_ADDRESS AIGW_SMTP_ADDRESS_DOCKER AIGW_STRIPE_API_KEY AIGW_STRIPE_WEBHOOK_SECRET AIGW_STRIPE_SUCCESS_URL AIGW_STRIPE_CANCEL_URL; do
+ grep -q "^${required_name}=." "$env_file" || fail "$required_name is missing from $env_file; compare it with .env.control.example"
+done
cd "$repo_dir"
if [[ "${AIGW_DEBUG_SKIP_BUILD:-0}" == "1" ]]; then
@@ -47,7 +68,7 @@ else
docker build --network="$build_network" -t aigw-debug:local .
fi
-log "starting PostgreSQL, Redis, and gateway"
+log "starting PostgreSQL, Redis, Mailpit, and gateway"
if ! docker compose --env-file "$env_file" up -d --no-build --wait --wait-timeout 120; then
docker compose --env-file "$env_file" ps >&2 || true
gateway_logs="$(docker compose --env-file "$env_file" logs --no-color --tail=120 aigw 2>&1 || true)"
@@ -60,10 +81,10 @@ if ! docker compose --env-file "$env_file" up -d --no-build --wait --wait-timeou
fi
log "services are ready"
-printf '\nAdmin UI: http://127.0.0.1:8080/admin/\n'
+printf '\nAdmin UI: http://localhost:8080/admin/\n'
+printf 'Mail inbox: http://127.0.0.1:8025/\n'
printf 'Health: http://127.0.0.1:8080/readyz\n'
-printf 'Admin token: %s\n' "$admin_token"
-printf 'Environment: %s\n' "$env_file"
+printf 'Secrets: %s (mode 0600)\n' "$env_file"
printf '\nLogs: docker compose --env-file %q logs -f aigw\n' "$env_file"
printf 'Stop: ./scripts/stop-debug.sh\n'
diff --git a/scripts/stop-debug.sh b/scripts/stop-debug.sh
index 8976d2c..43de07d 100755
--- a/scripts/stop-debug.sh
+++ b/scripts/stop-debug.sh
@@ -14,10 +14,18 @@ command -v docker >/dev/null 2>&1 || {
if [[ -f "$env_file" ]]; then
compose=(docker compose --env-file "$env_file")
else
+ export AIGW_SERVER_ADDRESS=:8080
+ export AIGW_POSTGRES_USER=debug-stop-placeholder
+ export AIGW_POSTGRES_PASSWORD=debug-stop-placeholder
+ export AIGW_POSTGRES_DB=debug-stop-placeholder
+ export AIGW_DATABASE_URL_DOCKER=postgres://debug-stop-placeholder:debug-stop-placeholder@postgres:5432/debug-stop-placeholder
+ export AIGW_REDIS_URL_DOCKER=
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
+ export AIGW_STRIPE_SUCCESS_URL=http://127.0.0.1:8080/admin/?topup=success
+ export AIGW_STRIPE_CANCEL_URL=http://127.0.0.1:8080/admin/?topup=cancel
compose=(docker compose)
fi