Skip to content

Commit f530d1a

Browse files
committed
feat: auto-pull ollama models on startup via ollama-init service
1 parent 32b4ccf commit f530d1a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,31 @@ services:
3030
networks:
3131
- ifinho-network
3232

33+
ollama-init:
34+
container_name: ifinho-ollama-init
35+
image: ollama/ollama
36+
profiles:
37+
- prod
38+
entrypoint: ["/bin/sh", "-c"]
39+
command:
40+
- |
41+
echo "Waiting for Ollama to be ready..."
42+
until ollama list > /dev/null 2>&1; do
43+
sleep 2
44+
done
45+
echo "Pulling model: ${OLLAMA_MODEL:-llama3.2}"
46+
ollama pull ${OLLAMA_MODEL:-llama3.2}
47+
echo "Pulling embed model: ${OLLAMA_EMBED_MODEL:-nomic-embed-text}"
48+
ollama pull ${OLLAMA_EMBED_MODEL:-nomic-embed-text}
49+
echo "Models ready."
50+
environment:
51+
OLLAMA_HOST: http://ifinho-ollama:11434
52+
depends_on:
53+
- ollama
54+
networks:
55+
- ifinho-network
56+
restart: "no"
57+
3358
server:
3459
container_name: ifinho-server
3560
build:
@@ -48,6 +73,8 @@ services:
4873
depends_on:
4974
postgres:
5075
condition: service_healthy
76+
ollama-init:
77+
condition: service_completed_successfully
5178
healthcheck:
5279
test: ["CMD-SHELL", "wget -qO- http://localhost:3000/ || exit 1"]
5380
interval: 10s

0 commit comments

Comments
 (0)