oolama / entrypoint.sh
cometapii's picture
Upload 3 files
1f2477d verified
raw
history blame
1.06 kB
#!/bin/bash
set -e
echo "==> Starting Ollama server on port 7860..."
export OLLAMA_HOST=0.0.0.0:7860
export OLLAMA_MODELS=/home/user/.ollama/models
# Start ollama in foreground
ollama serve &
OLLAMA_PID=$!
# Wait for ollama to be ready
echo "==> Waiting for Ollama to be ready..."
MAX_RETRIES=30
COUNT=0
until curl -s http://localhost:7860/api/version > /dev/null 2>&1; do
COUNT=$((COUNT + 1))
if [ $COUNT -ge $MAX_RETRIES ]; then
echo "ERROR: Ollama did not start in time."
exit 1
fi
echo " ... attempt $COUNT/$MAX_RETRIES"
sleep 2
done
echo "==> Ollama is ready!"
# Pull model if not cached (fallback in case build layer failed)
if ! ollama list | grep -q "granite4"; then
echo "==> Pulling granite4:350m..."
ollama pull granite4:350m
fi
echo "==> Model available:"
ollama list
echo "==> Ollama API running at http://0.0.0.0:7860"
echo "==> Endpoints:"
echo " POST /api/generate"
echo " POST /api/chat"
echo " GET /api/tags"
echo " POST /api/embeddings"
# Keep process alive
wait $OLLAMA_PID