b2 / entrypoint.sh
MakPr016's picture
Updated Ollama install
861de21 verified
Raw
History Blame Contribute Delete
818 Bytes
#!/bin/bash
set -e
echo "==> Starting Ollama server..."
mkdir -p /app/models
ollama serve &
OLLAMA_PID=$!
# Wait up to 60s for Ollama to be ready
echo "==> Waiting for Ollama to be ready..."
READY=0
for i in $(seq 1 20); do
if curl -sf http://localhost:11434/api/tags > /dev/null 2>&1; then
echo "==> Ollama is ready (attempt $i)."
READY=1
break
fi
echo " Attempt $i/20 — retrying in 3s..."
sleep 3
done
if [ "$READY" -eq 0 ]; then
echo "ERROR: Ollama never became ready. Dumping process list:"
ps aux
exit 1
fi
# Pull the model (no-op if already cached)
echo "==> Pulling model: ${MODEL_TAG}"
ollama pull "${MODEL_TAG}"
echo "==> Model ready."
# Start FastAPI on 7860
echo "==> Starting FastAPI on :7860..."
exec uvicorn app:app --host 0.0.0.0 --port 7860