File size: 778 Bytes
095871d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# Bake the model into the image at build time.
set -e

mkdir -p "$OLLAMA_MODELS"

ollama serve &
SERVER_PID=$!

i=0
until curl -sf http://127.0.0.1:11434/api/tags >/dev/null 2>&1; do
  i=$((i + 1))
  if [ "$i" -gt 120 ]; then
    echo "ollama did not come up within 120s"
    exit 1
  fi
  sleep 1
done

ollama pull granite4:micro

# Stop it by PID, not by pattern.
#
# `pkill -f "ollama serve"` matches this script's own command line inside the
# Docker build, so it SIGTERMs the build step and the layer fails with exit
# 143 immediately after a successful pull, which reads like the pull failed.
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true

# Give the manifest write a moment to flush before the layer is committed.
sleep 2
exit 0