Spaces:
Build error

trackademi / docker-entrypoint.sh
anwarKXC
revert: drop alembic from the container entrypoint
ddb1f54
Raw History Blame Contribute Delete
1.23 kB
#!/bin/bash
set -e
MODEL_NAME="nomic-embed-text"
echo "[Entrypoint] Starting Ollama (localhost only)..."
# OLLAMA_HOST and OLLAMA_MODELS are set via Dockerfile ENV
ollama serve &
OLLAMA_PID=$!
# Model is pre-baked — Ollama starts fast, no download needed
echo "[Entrypoint] Waiting for Ollama to be ready..."
for i in $(seq 1 20); do
if curl -s http://localhost:11434/api/tags > /dev/null 2>&1; then
echo "[Entrypoint] Ollama ready."
break
fi
if [ "$i" -eq 20 ]; then
echo "[Entrypoint] ERROR: Ollama failed to start after 20s"
kill "$OLLAMA_PID" 2>/dev/null || true
exit 1
fi
sleep 1
done
# Verify model is present (fail fast if image was built incorrectly)
if ! ollama list | grep -q "$MODEL_NAME"; then
echo "[Entrypoint] ERROR: ${MODEL_NAME} not found in image — rebuild required"
exit 1
fi
# Warmup: load model into RAM so the first real embed request is fast
echo "[Entrypoint] Warming up embedding model..."
curl -s http://localhost:11434/api/embeddings \
-d "{\"model\":\"${MODEL_NAME}\",\"prompt\":\"warmup\"}" \
> /dev/null 2>&1 || true
echo "[Entrypoint] Starting FastAPI..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8000