| # Function to start Ollama server | |
| start_server() { | |
| echo "Starting Ollama server" | |
| ollama serve & | |
| SERVER_PID=$! | |
| } | |
| # Function to wait for server readiness | |
| wait_for_server() { | |
| echo "Waiting for server to start..." | |
| while ! nc -z localhost 11434; do | |
| sleep 1 | |
| done | |
| } | |
| # Function to pull model | |
| pull_model() { | |
| echo "Pulling all-minilm model" | |
| ollama pull all-minilm | |
| } | |
| # Main execution | |
| start_server | |
| wait_for_server | |
| pull_model | |
| # Keep container running by waiting for server process | |
| wait $SERVER_PID |