Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
167 lines (158 loc) · 5.1 KB
/
Copy pathdocker-compose.yml
File metadata and controls
167 lines (158 loc) · 5.1 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: deepref
x-llama-healthcheck: &llama-healthcheck
test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"]
interval: 15s
timeout: 5s
retries: 10
# The first start downloads the model from Hugging Face; allow time for that.
start_period: 20m
services:
db:
image: pgvector/pgvector:pg17
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-deepref}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
POSTGRES_DB: ${POSTGRES_DB:-deepref}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 10
# RustFS: S3-compatible object storage for uploaded PDFs and other assets.
rustfs:
image: ${RUSTFS_IMAGE:-rustfs/rustfs:1.0.1@sha256:1803faef57627e2d9c2e7d89d655d712ddded5389040054987163043fecb6a3c}
restart: unless-stopped
environment:
RUSTFS_ACCESS_KEY: ${RUSTFS_ROOT_USER:?set RUSTFS_ROOT_USER in .env}
RUSTFS_SECRET_KEY: ${RUSTFS_ROOT_PASSWORD:?set RUSTFS_ROOT_PASSWORD in .env}
RUSTFS_CONSOLE_ENABLE: "true"
volumes:
- rustfsdata:/data
ports:
# Web console on localhost only. The S3 API stays internal: the browser gets files
# through the backend, which checks ownership on every download.
- "127.0.0.1:9001:9001"
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:9000/health/ready"]
interval: 5s
timeout: 5s
retries: 20
# One-shot setup with RustFS's `rc` CLI: private bucket + an app user restricted to that
# bucket, so the backend never holds the RustFS root credentials. Safe to re-run.
rustfs-init:
image: ${RUSTFS_CLI_IMAGE:-rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699}
entrypoint: ["/bin/sh", "/rustfs-init.sh"]
environment:
S3_ENDPOINT_URL: http://rustfs:9000
RUSTFS_ROOT_USER: ${RUSTFS_ROOT_USER}
RUSTFS_ROOT_PASSWORD: ${RUSTFS_ROOT_PASSWORD}
S3_BUCKET: ${S3_BUCKET:-deepref}
S3_ACCESS_KEY: ${S3_ACCESS_KEY:?set S3_ACCESS_KEY in .env}
S3_SECRET_KEY: ${S3_SECRET_KEY:?set S3_SECRET_KEY in .env}
volumes:
- ./infra/rustfs-init.sh:/rustfs-init.sh:ro
depends_on:
rustfs:
condition: service_healthy
restart: "no"
# SmolLM2-1.7B-Instruct (GGUF Q4_K_M, ~1.06 GB) served by llama.cpp with an OpenAI-compatible API.
llm:
image: ghcr.io/ggml-org/llama.cpp:server
restart: unless-stopped
environment:
LLAMA_CACHE: /models
command:
- --hf-repo
- ${LLM_HF_REPO:-HuggingFaceTB/SmolLM2-1.7B-Instruct-GGUF}
- --hf-file
- ${LLM_HF_FILE:-smollm2-1.7b-instruct-q4_k_m.gguf}
- --alias
- smollm2-1.7b-instruct
- --host
- 0.0.0.0
- --port
- "8080"
# Total context is split across parallel slots: 8192 / 2 = 4096 tokens per request.
- --ctx-size
- ${LLM_CTX_SIZE:-8192}
- --parallel
- ${LLM_PARALLEL:-2}
- --threads
- ${LLM_THREADS:-4}
# llama.cpp caches past prompts in RAM, 8 GiB by default: more than a typical Docker VM.
# RAG prompts rarely repeat (each has different passages), so a small cache loses little.
- --cache-ram
- ${LLM_CACHE_RAM_MB:-512}
- --jinja
volumes:
- models:/models
# Model (~1 GB) + KV cache (~1.6 GB at 8192 ctx) + prompt cache + buffers. If it ever grows
# past this, only this container restarts instead of the kernel killing Postgres or RustFS.
mem_limit: ${LLM_MEM_LIMIT:-5g}
healthcheck: *llama-healthcheck
# bge-small-en-v1.5 (384-dim) embeddings, also served by llama.cpp.
embeddings:
image: ghcr.io/ggml-org/llama.cpp:server
restart: unless-stopped
environment:
LLAMA_CACHE: /models
command:
- --hf-repo
- CompendiumLabs/bge-small-en-v1.5-gguf
- --hf-file
- bge-small-en-v1.5-q8_0.gguf
- --alias
- bge-small-en-v1.5
- --embedding
- --pooling
- cls
- --host
- 0.0.0.0
- --port
- "8080"
- --ctx-size
- "2048"
- --parallel
- "4"
volumes:
- models:/models
healthcheck: *llama-healthcheck
backend:
build: ./backend
restart: unless-stopped
env_file: .env
environment:
POSTGRES_HOST: db
LLM_BASE_URL: http://llm:8080/v1
EMBEDDING_BASE_URL: http://embeddings:8080/v1
S3_ENDPOINT_URL: http://rustfs:9000
ports:
# Exposed on localhost only, for the interactive API docs at /api/v1/docs.
- "127.0.0.1:8000:8000"
depends_on:
db:
condition: service_healthy
rustfs-init:
condition: service_completed_successfully
embeddings:
condition: service_healthy
llm:
condition: service_started
frontend:
build: ./frontend
restart: unless-stopped
environment:
BACKEND_URL: http://backend:8000
COOKIE_SECURE: ${COOKIE_SECURE:-false}
ports:
- "3000:3000"
depends_on:
backend:
condition: service_healthy
volumes:
pgdata:
models:
rustfsdata: