Spaces:
Running
Running
| # 1. Set the OLLAMA_HOST to listen on all interfaces (CRITICAL NETWORK FIX for Docker) | |
| export OLLAMA_HOST=0.0.0.0 | |
| # 2. Start Ollama in the background | |
| echo "Starting Ollama server in background (listening on $OLLAMA_HOST:11434)..." | |
| ollama serve & | |
| # 3. Wait for the Ollama server process to initialize | |
| echo "Waiting 45 seconds for Ollama server to fully initialize..." | |
| sleep 45 | |
| # 4. Pull and CONFIRM MODEL READINESS (Pre-load the model) | |
| MODEL="moondream:1.8b" | |
| echo "Ensuring model $MODEL is pulled and ready..." | |
| # Pull and force a synchronous run to load the model into VRAM | |
| ollama pull "$MODEL" | |
| ollama run "$MODEL" "Describe a house" --verbose --system "You are a helpful assistant." --keep < /dev/null | |
| # 5. Start the Gradio web application | |
| echo "Starting Gradio application on port 7860..." | |
| exec python app.py |