83d516afa1
FastAPI gateway with A/B/C lane orchestration, LiteLLM proxy config, Swarm stack (postgres, redis, VPN off-by-default), deploy/smoke/audit scripts.
67 lines
2.2 KiB
Bash
67 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Deploy AI Router stack to Docker Swarm (IFT)
|
|
set -euo pipefail
|
|
|
|
STACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
STACK_NAME="${STACK_NAME:-ai-router}"
|
|
|
|
cd "$STACK_DIR"
|
|
|
|
if [[ ! -f .env ]]; then
|
|
echo "ERROR: copy .env.example to .env and fill secrets" >&2
|
|
exit 1
|
|
fi
|
|
|
|
set -a
|
|
# shellcheck disable=SC1091
|
|
source .env
|
|
set +a
|
|
|
|
ensure_secret() {
|
|
local name="$1"
|
|
local value="$2"
|
|
if docker secret inspect "$name" >/dev/null 2>&1; then
|
|
echo "secret exists: $name"
|
|
else
|
|
echo -n "$value" | docker secret create "$name" -
|
|
echo "created secret: $name"
|
|
fi
|
|
}
|
|
|
|
echo "== Ensure Swarm secrets =="
|
|
ensure_secret novita_api_key "${NOVITA_API_KEY:?NOVITA_API_KEY required}"
|
|
ensure_secret litellm_master_key "${LITELLM_MASTER_KEY:?LITELLM_MASTER_KEY required}"
|
|
ensure_secret litellm_salt_key "${LITELLM_SALT_KEY:?LITELLM_SALT_KEY required}"
|
|
ensure_secret router_api_key "${ROUTER_API_KEY:?ROUTER_API_KEY required}"
|
|
ensure_secret postgres_password "${POSTGRES_PASSWORD:?POSTGRES_PASSWORD required}"
|
|
ensure_secret groq_api_key "${GROQ_API_KEY:-}"
|
|
ensure_secret gemini_api_key "${GEMINI_API_KEY:-}"
|
|
|
|
if [[ ! -f vless/vless.conf ]]; then
|
|
echo "WARN: vless/vless.conf missing — stub for secret (VPN off until configured)"
|
|
cp vless/vless.conf.example vless/vless.conf 2>/dev/null || echo "# stub" > vless/vless.conf
|
|
fi
|
|
ensure_secret vless_conf "$(cat vless/vless.conf)"
|
|
|
|
echo "== Build images =="
|
|
docker build -f router/Dockerfile -t "${ROUTER_IMAGE:-git.sabilin.com/eventhub/ai-router-gateway:ift}" .
|
|
docker build -t ai-router/vless-proxy:local ./vless
|
|
docker build -t ai-router/vpn-watchdog:local ./watchdog
|
|
|
|
echo "== Sync routing config (optional regen) =="
|
|
bash scripts/sync-routing-config.sh || true
|
|
|
|
echo "== Deploy stack: ${STACK_NAME} =="
|
|
docker stack deploy -c docker-stack.yml --with-registry-auth "${STACK_NAME}"
|
|
|
|
echo "== Wait for services =="
|
|
sleep 8
|
|
docker stack services "${STACK_NAME}"
|
|
|
|
echo ""
|
|
echo "Done."
|
|
echo " Zed URL: ${TEST_BASE_URL:-https://ai-router.ift.calentiq.com}/v1"
|
|
echo " LiteLLM: ${TEST_LITELLM_URL:-https://litellm.ift.calentiq.com}/ui"
|
|
echo " Smoke: bash scripts/smoke-test.sh"
|
|
echo " VPN on: bash scripts/vpn-enable.sh"
|