#!/usr/bin/env bash set -euo pipefail if [[ "${CI:-}" == "true" ]]; then # ── CI path ──────────────────────────────────────────────────────── cd /app/services/ponder echo "[ponder-ci] Starting Ponder indexer..." : "${DATABASE_URL:?DATABASE_URL is required}" : "${PONDER_RPC_URL_1:?PONDER_RPC_URL_1 is required}" export PONDER_RPC_TIMEOUT=${PONDER_RPC_TIMEOUT:-20000} export HOST=${HOST:-0.0.0.0} export PORT=${PORT:-42069} cat > .env.local </dev/null | cut -d= -f2 || echo "") EXPECTED_SCHEMA="ponder_local_${START_BLOCK}" # Check if schema changed (contract redeployment detected) if [[ -n "$START_BLOCK" ]]; then CURRENT_SCHEMA=$(grep DATABASE_SCHEMA .env.local 2>/dev/null | cut -d= -f2 || echo "") if [[ -n "$CURRENT_SCHEMA" && "$CURRENT_SCHEMA" != "$EXPECTED_SCHEMA" ]]; then echo "[ponder-entrypoint] Contract redeployment detected (schema changed: $CURRENT_SCHEMA -> $EXPECTED_SCHEMA)" echo "[ponder-entrypoint] Resetting Ponder database..." export PGPASSWORD=ponder_local psql -h postgres -U ponder -d ponder_local -c \ "DROP SCHEMA IF EXISTS \"$CURRENT_SCHEMA\" CASCADE;" 2>/dev/null || true echo "[ponder-entrypoint] Old schema dropped successfully" fi fi entrypoint_require_kraiken_lib "$ROOT_DIR" "ponder-entrypoint" entrypoint_install_deps "ponder-entrypoint" # Load and export all environment variables from .env.local if [[ -f .env.local ]]; then echo "[ponder-entrypoint] Loading environment from .env.local" set -a source .env.local set +a fi export CHOKIDAR_USEPOLLING=${CHOKIDAR_USEPOLLING:-1} export HOST=0.0.0.0 export PORT=${PORT:-42069} export PONDER_RPC_TIMEOUT=${PONDER_RPC_TIMEOUT:-20000} exec npm run dev