-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.cpu.yml
More file actions
145 lines (138 loc) · 4.08 KB
/
docker-compose.cpu.yml
File metadata and controls
145 lines (138 loc) · 4.08 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Docker Compose configuration for CPU-only systems (no NVIDIA GPU)
# Usage: docker compose -f docker-compose.cpu.yml up --build
services:
# PostgreSQL database for document storage
postgres:
image: postgres:16-alpine
container_name: ai-agent-postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${DATABASE_USER:-postgres}
- POSTGRES_PASSWORD=${DATABASE_PASSWORD:-postgres}
- POSTGRES_DB=${DATABASE_NAME:-ai_agent}
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DATABASE_USER:-postgres} -d ${DATABASE_NAME:-ai_agent}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
# Qdrant vector database for RAG
qdrant:
image: qdrant/qdrant:latest
container_name: ai-agent-qdrant
ports:
- "6333:6333"
- "6334:6334"
volumes:
- qdrant-data:/qdrant/storage
healthcheck:
test: ["CMD-SHELL", "bash -c 'exec 3<>/dev/tcp/localhost/6333'"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
# Ollama service - runs the LLM (CPU mode)
ollama:
image: ollama/ollama:latest
container_name: ai-agent-ollama
ports:
- "11434:11434"
volumes:
- ollama-data:/root/.ollama
healthcheck:
test: ["CMD-SHELL", "ollama list || exit 1"]
interval: 10s
timeout: 10s
retries: 10
start_period: 30s
restart: unless-stopped
# Ollama model puller - pulls the required models (LLM + Embedding)
ollama-pull:
image: curlimages/curl:latest
container_name: ai-agent-ollama-pull
depends_on:
ollama:
condition: service_healthy
environment:
- OLLAMA_MODEL=${OLLAMA_MODEL:-llama3.2:1b}
- EMBEDDING_MODEL=${EMBEDDING_MODEL:-nomic-embed-text}
entrypoint:
- sh
- -c
- |
echo "Waiting for Ollama to be ready..." &&
sleep 5 &&
echo "Pulling LLM model: $$OLLAMA_MODEL..." &&
curl -X POST http://ollama:11434/api/pull -d "{\"name\": \"$$OLLAMA_MODEL\"}" &&
echo "Pulling embedding model: $$EMBEDDING_MODEL..." &&
curl -X POST http://ollama:11434/api/pull -d "{\"name\": \"$$EMBEDDING_MODEL\"}" &&
echo "All models pulled successfully!"
restart: "no"
# Backend service - NestJS API
backend:
build:
context: .
dockerfile: apps/backend/Dockerfile
container_name: ai-agent-backend
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- PORT=3001
- OLLAMA_BASE_URL=http://ollama:11434
- OLLAMA_MODEL=${OLLAMA_MODEL:-llama3.2:1b}
- EMBEDDING_MODEL=${EMBEDDING_MODEL:-nomic-embed-text}
- SYSTEM_PROMPT=${SYSTEM_PROMPT:-}
- CORS_ORIGINS=http://localhost:3000,http://frontend:3000
# PostgreSQL
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USER=${DATABASE_USER:-postgres}
- DATABASE_PASSWORD=${DATABASE_PASSWORD:-postgres}
- DATABASE_NAME=${DATABASE_NAME:-ai_agent}
# Qdrant
- QDRANT_URL=http://qdrant:6333
- QDRANT_COLLECTION=${QDRANT_COLLECTION:-documents}
depends_on:
ollama:
condition: service_healthy
postgres:
condition: service_healthy
qdrant:
condition: service_healthy
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3001/chat/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
# Frontend service - Next.js app
frontend:
build:
context: .
dockerfile: apps/frontend/Dockerfile
args:
- NEXT_PUBLIC_API_URL=http://localhost:3001
container_name: ai-agent-frontend
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- PORT=3000
depends_on:
backend:
condition: service_healthy
restart: unless-stopped
volumes:
ollama-data:
driver: local
postgres-data:
driver: local
qdrant-data:
driver: local