Spaces:
Sleeping
Sleeping
| 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}" | |