#!/usr/bin/env bash # Pulls ollama/ollama:latest, starts it once, pulls qwen2.5:0.5b (chat, ~400MB) and all-minilm # (embeddings, ~45MB) inside the running container, then `docker commit`s the result to a local # image tag. This is the real Testcontainers-recommended pattern for CI: bake the models into # an image once, and every subsequent test run starts a container that already has them on # disk -- no registry pull, no flaky network dependency, no per-run latency for the pull itself. # # Run this once before scripts/run-all.sh, or whenever you want to refresh the baked models. set -euo pipefail IMAGE_TAG="${1:-ollama-baked-qwen05b-minilm:local}" CONTAINER_NAME="ollama-bake-$$" echo "Pulling ollama/ollama:latest..." docker pull ollama/ollama:latest echo "Starting a container to pull models into..." docker run -d --name "$CONTAINER_NAME" ollama/ollama:latest trap 'docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true' EXIT echo "Waiting for the Ollama server to accept connections..." until docker exec "$CONTAINER_NAME" ollama list >/dev/null 2>&1; do sleep 1 done echo "Pulling qwen2.5:0.5b (chat)..." docker exec "$CONTAINER_NAME" ollama pull qwen2.5:0.5b echo "Pulling all-minilm (embeddings)..." docker exec "$CONTAINER_NAME" ollama pull all-minilm echo "Committing to ${IMAGE_TAG}..." docker commit "$CONTAINER_NAME" "$IMAGE_TAG" echo "Done. ${IMAGE_TAG} now has both models baked in -- scripts/run-all.sh will not touch the network."