ig-v1 / docker-entrypoint.sh
harshith99's picture
HF deploy: container hosted-readiness + client-side geocoding (#8–#11)
8d29bb2
Raw
History Blame Contribute Delete
1.44 kB
#!/bin/sh
set -e
# Two deployment modes share this entrypoint (see DEPLOY.md):
# - Local Docker : OLLAMA_ENABLED=true -> wait for Ollama + pull the model
# - Hosted free web: OLLAMA_ENABLED=false -> start the server directly
# Hosted mode has NO Ollama service, so the wait/pull below must be skipped or
# the container would hang forever waiting for a server that never appears.
PORT="${PORT:-8000}"
case "$(echo "${OLLAMA_ENABLED:-true}" | tr '[:upper:]' '[:lower:]')" in
0|false|no)
echo "OLLAMA_ENABLED=false β€” hosted mode, skipping Ollama. Starting server…"
exec uvicorn web.app:app --host 0.0.0.0 --port "${PORT}"
;;
esac
# ── Local Docker mode: bring up Ollama, then the server ──────────────────────
OLLAMA_URL="${OLLAMA_URL:-http://ollama:11434}"
MODEL="${DEFAULT_OLLAMA_MODEL:-llama3.2}"
echo "Waiting for Ollama at ${OLLAMA_URL}…"
until curl -sf "${OLLAMA_URL}/api/tags" > /dev/null 2>&1; do
sleep 2
done
echo "Ollama ready."
# Pull the default model on first run if not already cached
if ! curl -sf "${OLLAMA_URL}/api/tags" | grep -q "\"${MODEL}\""; then
echo "Pulling ${MODEL} (one-time download, ~2 GB)…"
curl -sf "${OLLAMA_URL}/api/pull" \
-H "Content-Type: application/json" \
-d "{\"name\":\"${MODEL}\"}" \
--no-buffer -o /dev/null
echo "${MODEL} ready."
fi
exec uvicorn web.app:app --host 0.0.0.0 --port "${PORT}"