#!/usr/bin/env bash # ZizkaDB OSS quickstart — NO git clone (when GHCR images are public). # Downloads ~4 small files to ~/.zizkadb, pulls pre-built Docker images, runs db.why() demo. # If GHCR pull fails, automatically shallow-clones and builds locally. # # curl -fsSL https://raw.githubusercontent.com/Zizka-ai/ZizkaDB/main/scripts/quickstart-remote.sh | bash # set -euo pipefail REF="${ZIZKADB_REF:-main}" REPO="${ZIZKADB_REPO:-Zizka-ai/ZizkaDB}" BASE="https://raw.githubusercontent.com/${REPO}/${REF}" INSTALL_DIR="${ZIZKADB_HOME:-${HOME}/.zizkadb}" INFRA="${INSTALL_DIR}/infra" CLONE_DIR="${INSTALL_DIR}/repo" echo "════════════════════════════════════════════════════════" echo " ZizkaDB — remote quickstart (no repo clone)" echo "════════════════════════════════════════════════════════" echo "" echo " Install dir: ${INSTALL_DIR}" echo "" if ! command -v docker >/dev/null 2>&1; then echo "ERROR: Docker is required. https://docs.docker.com/get-docker/" >&2 exit 1 fi if ! docker info >/dev/null 2>&1; then echo "ERROR: Docker daemon not running. Start Docker Desktop or OrbStack." >&2 exit 1 fi run_demo() { if ! command -v python3 >/dev/null 2>&1; then echo "WARN: python3 not found — stack is up but demo skipped." echo " pip install zizkadb-sdk && zizkadb demo" return 0 fi # Install the SDK into a private venv so the demo never depends on (or # modifies) the caller's Python: active venvs, pip "user = true" config, # PEP 668 externally-managed system Pythons, broken editable installs. local venv="${INSTALL_DIR}/venv" local py=python3 echo "→ Installing SDK from PyPI (private venv: ${venv})..." if [ -x "${venv}/bin/python" ] || python3 -m venv "$venv" >/dev/null 2>&1; then py="${venv}/bin/python" PIP_USER=0 "$py" -m pip install -q --disable-pip-version-check --upgrade zizkadb-sdk else echo "WARN: could not create a venv (python3-venv missing?) — installing into python3." PIP_USER=0 python3 -m pip install -q --disable-pip-version-check zizkadb-sdk fi echo "" echo "→ Running causal lineage demo..." "$py" -m zizkadb.cli demo || "$py" -c " import asyncio from zizkadb import ZizkaDB async def main(): async with ZizkaDB(host='http://localhost:8000') as db: u = await db.log(agent='support-bot', event='user_message', data={'text': 'Why was my order delayed?'}) r = await db.log(agent='support-bot', event='llm_response', data={'model': 'gpt-4o'}, parent_id=u.event_id) t = await db.log(agent='support-bot', event='tool_call', data={'tool': 'lookup_order'}, parent_id=r.event_id) (await db.why(t.event_id)).print() asyncio.run(main()) " echo "" echo "════════════════════════════════════════════════════════" echo " Done" echo "════════════════════════════════════════════════════════" echo "" echo " Dashboard: http://localhost:3001/dashboard/activity?agent=support-bot" echo " (login gate: http://localhost:3001/login → Open my dashboard →)" echo " API: http://localhost:8000/health" echo " Connect: https://github.com/${REPO}/blob/${REF}/CONNECT.md" echo " Demo again: ${py} -m zizkadb.cli demo" echo "" } fallback_shallow_clone() { echo "" echo "→ GHCR pre-built images unavailable — falling back to shallow clone + local build..." echo " (First run may take a few minutes while Docker builds api + dashboard.)" echo "" if ! command -v git >/dev/null 2>&1; then echo "ERROR: git is required for the build fallback." >&2 echo " Install git, or run:" >&2 echo " git clone https://github.com/${REPO}.git && cd ZizkaDB && bash scripts/quickstart.sh" >&2 exit 1 fi rm -rf "${CLONE_DIR}" git clone --depth 1 --branch "${REF}" "https://github.com/${REPO}.git" "${CLONE_DIR}" exec bash "${CLONE_DIR}/scripts/quickstart.sh" } mkdir -p "${INFRA}" echo "→ Downloading compose + schema (not the full repo)..." curl -fsSL "${BASE}/infra/docker-compose.quickstart.yml" -o "${INFRA}/docker-compose.quickstart.yml" curl -fsSL "${BASE}/core/db/schema.sql" -o "${INFRA}/schema.sql" curl -fsSL "${BASE}/infra/.env.quickstart" -o "${INFRA}/.env" echo "→ Pulling pre-built images from ghcr.io/zizka-ai-sl/ (first run may take 5–10 min)..." cd "${INFRA}" if ! docker compose -f docker-compose.quickstart.yml pull; then fallback_shallow_clone fi echo "→ Starting stack (postgres, qdrant, redis, api, dashboard)..." # Recreate so containers from a clone-based setup (same project "infra") never # keep a stale network reference. Data lives in volumes. docker compose -f docker-compose.quickstart.yml up -d --force-recreate --remove-orphans echo "→ Waiting for API..." for i in $(seq 1 60); do if curl -sf http://localhost:8000/health >/dev/null 2>&1; then break fi sleep 2 if [ "$i" -eq 60 ]; then echo "ERROR: API did not become healthy. Check: docker compose -f ${INFRA}/docker-compose.quickstart.yml logs api" >&2 exit 1 fi done curl -fsSL "${BASE}/scripts/telemetry-install-ping.sh" -o "${INSTALL_DIR}/telemetry-install-ping.sh" bash "${INSTALL_DIR}/telemetry-install-ping.sh" docker oss || true run_demo echo " Stop: cd ${INFRA} && docker compose -f docker-compose.quickstart.yml down" echo ""