#!/bin/bash set -e echo "=========================================" echo " CCPA Compliance Analyzer — Starting Up" echo "=========================================" # ── Start Ollama in background ──────────────────────────────── echo "[1/3] Starting Ollama server..." ollama serve & OLLAMA_PID=$! # ── Wait for Ollama to be ready ─────────────────────────────── echo "[2/3] Waiting for Ollama to become ready..." MAX_WAIT=120 ELAPSED=0 until curl -sf http://localhost:11434/api/tags > /dev/null 2>&1; do if [ $ELAPSED -ge $MAX_WAIT ]; then echo "ERROR: Ollama did not start within ${MAX_WAIT}s. Exiting." exit 1 fi sleep 3 ELAPSED=$((ELAPSED + 3)) done echo "Ollama is ready after ${ELAPSED}s." # ── Verify model is available (already baked in during build) ─ MODEL="${MODEL_NAME:-llama3.2:3b}" echo "Using model: $MODEL" if ! ollama list | grep -q "$MODEL"; then echo "Model not found in image — pulling now (fallback)..." ollama pull "$MODEL" fi # ── Start FastAPI server ────────────────────────────────────── echo "[3/3] Starting FastAPI server on port 8000..." exec uvicorn app:app \ --host 0.0.0.0 \ --port 8000 \ --workers 1 \ --log-level info