| # Use the official Ollama image | |
| FROM ollama/ollama:latest | |
| # 1. Force the port for Hugging Face Spaces | |
| ENV OLLAMA_HOST=0.0.0.0:7860 | |
| # 2. Fix the 403 Error by allowing CORS (so your HTML UI works) | |
| ENV OLLAMA_ORIGINS="*" | |
| # 3. Bake the massive 9B model into the image so you don't wait 6 minutes next time | |
| RUN nohup bash -c "ollama serve &" && \ | |
| sleep 5 && \ | |
| ollama pull qwen2.5:3b && \ | |
| pkill ollama | |
| # Expose the port | |
| EXPOSE 7860 | |
| # Start the server | |
| ENTRYPOINT ["ollama", "serve"] |