chore(installer): harden install.sh for Podman macOS & ARM64

- auto-start Podman machine VM on macOS if not already running
- fix host‐gateway handling to avoid empty host-gateway errors
- add explicit platform overrides for ARM64 hosts
- switch health checks to in-container `exec` calls
- formatting nits
This commit is contained in:
reluctantfuturist 2025-04-30 11:35:30 -07:00
parent 653e8526ec
commit 17992330a2

View file

@ -26,12 +26,39 @@ else
die "Docker or Podman is required. Install Docker: https://docs.docker.com/get-docker/ or Podman: https://podman.io/getting-started/installation"
fi
# Explicitly set the platform for the host architecture
HOST_ARCH="$(uname -m)"
if [ "$HOST_ARCH" = "arm64" ]; then
if [ "$ENGINE" = "docker" ]; then
PLATFORM_OPTS=( --platform linux/amd64 )
else
PLATFORM_OPTS=( --os linux --arch amd64 )
fi
else
PLATFORM_OPTS=()
fi
# macOS + Podman: ensure VM is running before we try to launch containers
if [ "$ENGINE" = "podman" ] && [ "$(uname -s)" = "Darwin" ]; then
if ! podman info &>/dev/null; then
log "⌛️ Initializing Podman VM…"
podman machine init -q &>/dev/null || true
podman machine start -q &>/dev/null || true
log "⌛️ Waiting for Podman API…"
until podman info &>/dev/null; do
sleep 1
done
log "✅ Podman VM is up"
fi
fi
# Clean up any leftovers from earlier runs
for name in ollama-server llama-stack; do
ids=$($ENGINE ps -aq --filter "name=^${name}$")
if [ -n "$ids" ]; then
log "⚠️ Found existing container(s) for '${name}', removing..."
$ENGINE rm -f "$ids"
log "⚠️ Found existing container(s) for '${name}', removing"
$ENGINE rm -f "$ids" > /dev/null 2>&1
fi
done
@ -39,7 +66,8 @@ done
# 1. Ollama
###############################################################################
log "🦙 Starting Ollama…"
$ENGINE run -d --name ollama-server \
$ENGINE run -d "${PLATFORM_OPTS[@]}" --name ollama-server \
-p "${OLLAMA_PORT}:11434" \
ollama/ollama > /dev/null 2>&1
@ -51,24 +79,29 @@ if ! timeout "$WAIT_TIMEOUT" bash -c \
die "Ollama startup failed"
fi
log "📦 Ensuring model is pulled: ${MODEL_ALIAS}..."
log "📦 Ensuring model is pulled: ${MODEL_ALIAS}"
$ENGINE exec ollama-server ollama pull "${MODEL_ALIAS}" > /dev/null 2>&1
###############################################################################
# 2. LlamaStack
###############################################################################
log "🦙📦 Starting LlamaStack…"
$ENGINE run -d --name llama-stack \
-p "${PORT}:${PORT}" \
--add-host="${HOST_DNS}:host-gateway" \
"${SERVER_IMAGE}" \
--port "${PORT}" \
if [ "$ENGINE" = "docker" ]; then
NET_OPTS=( -p "${PORT}:${PORT}" --add-host="${HOST_DNS}:host-gateway" )
elif [ "$ENGINE" = "podman" ]; then
NET_OPTS=( --network host )
fi
cmd=( run -d "${PLATFORM_OPTS[@]}" --name llama-stack "${NET_OPTS[@]}" \
"${SERVER_IMAGE}" --port "${PORT}" \
--env INFERENCE_MODEL="${MODEL_ALIAS}" \
--env OLLAMA_URL="http://${HOST_DNS}:${OLLAMA_PORT}" > /dev/null 2>&1
--env OLLAMA_URL="http://${HOST_DNS}:${OLLAMA_PORT}" )
log "🦙📦 Starting LlamaStack…"
$ENGINE "${cmd[@]}" > /dev/null 2>&1
log "⏳ Waiting for Llama-Stack API…"
if ! timeout "$WAIT_TIMEOUT" bash -c \
"until curl -fsS http://localhost:${PORT}/v1/health 2>/dev/null | grep -q 'OK'; do sleep 1; done"; then
"until $ENGINE exec llama-stack curl -fsS http://127.0.0.1:${PORT}/v1/health 2>/dev/null | grep -q 'OK'; do printf '.'; sleep 1; done"; then
log "❌ Llama-Stack did not become ready in ${WAIT_TIMEOUT}s; dumping container logs:"
$ENGINE logs llama-stack --tail=200
die "Llama-Stack startup failed"