Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
384 lines (371 loc) · 17.4 KB
/
Copy pathdocker-compose.yml
File metadata and controls
384 lines (371 loc) · 17.4 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# =============================================================================
# AnythingMCP — Full Stack Deployment (Single Container)
# =============================================================================
# Usage: docker compose up -d
# UI: http://localhost:3000
# API: http://localhost:4000
# MCP: http://localhost:4000/mcp
# =============================================================================
# Project name — also the prefix for the auto-created network and volumes.
# Override COMPOSE_PROJECT_NAME (in .env or the environment) to run more than
# one AnythingMCP stack on the same host without name collisions.
name: ${COMPOSE_PROJECT_NAME:-amcp}
services:
# Caddy Reverse Proxy (optional — enables HTTPS with automatic Let's Encrypt)
# Activated by COMPOSE_PROFILES=proxy in .env (setup.sh sets this automatically)
caddy:
image: caddy:2-alpine
profiles: ["proxy"]
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-caddy
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
app:
condition: service_healthy
restart: unless-stopped
# NestJS Backend + Next.js Frontend (single container)
app:
image: helpcodeai/anythingmcp:latest
build:
context: .
dockerfile: Dockerfile
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-app
# Bind published ports to loopback by default so the API/MCP endpoint is
# not exposed on every network interface out of the box. To reach it from
# the LAN or the public internet, set APP_BIND_IP=0.0.0.0 in .env (and put
# it behind the Caddy proxy / a firewall). The Caddy service talks to the
# app over the internal Docker network, so it is unaffected by this bind.
ports:
- "${APP_BIND_IP:-127.0.0.1}:${FRONTEND_PORT:-3000}:3000"
- "${APP_BIND_IP:-127.0.0.1}:${BACKEND_PORT:-4000}:4000"
environment:
- NODE_ENV=production
- PORT=4000
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:4000}
- DATABASE_URL=postgresql://amcp:${POSTGRES_PASSWORD:-amcp}@postgres:5432/anythingmcp
- JWT_SECRET=${JWT_SECRET:-change-me-in-production-min-32-chars}
# Signs the cookies of the sign-in and connect flows; empty = JWT_SECRET.
- COOKIE_SECRET=${COOKIE_SECRET:-}
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-change-me-in-production-exactly-32}
# `plaintext` only to roll back past encrypted connector variables (docs/operations/backup-restore.md)
- ENV_VARS_AT_REST=${ENV_VARS_AT_REST:-}
- CORS_ORIGIN=${CORS_ORIGIN:-http://localhost:3000}
- SERVER_URL=${SERVER_URL:-http://localhost:4000}
- FRONTEND_URL=${FRONTEND_URL:-http://localhost:3000}
# MCP Authentication (oauth2 | legacy | both | none)
# In `legacy`/`both` mode the /mcp endpoint requires MCP_API_KEY or
# MCP_BEARER_TOKEN. If neither is set, requests are REFUSED (401) unless
# MCP_ALLOW_ANONYMOUS=true is set explicitly — this avoids silently
# exposing configured MCP tools to unauthenticated network clients.
- MCP_AUTH_MODE=${MCP_AUTH_MODE:-legacy}
- MCP_API_KEY=${MCP_API_KEY:-}
- MCP_BEARER_TOKEN=${MCP_BEARER_TOKEN:-}
# Set to true ONLY for trusted local/dev use to allow unauthenticated
# /mcp access when no MCP credentials are configured (legacy mode).
- MCP_ALLOW_ANONYMOUS=${MCP_ALLOW_ANONYMOUS:-false}
# Registration (false = invite-only after first admin, true = anyone can register)
- ALLOW_OPEN_REGISTRATION=${ALLOW_OPEN_REGISTRATION:-false}
# Email (SMTP) for verification codes, invitations and password resets.
# setup.sh writes these into .env; without them here the app never saw
# them. Empty SMTP_HOST = no instance-wide mail (workspace admins can
# still set their own SMTP in Settings). SMTP_PORT defaults to 587;
# SMTP_SECURE=true for implicit TLS (port 465 implies it).
- SMTP_HOST=${SMTP_HOST:-}
- SMTP_PORT=${SMTP_PORT:-}
- SMTP_USER=${SMTP_USER:-}
- SMTP_PASS=${SMTP_PASS:-}
- SMTP_FROM=${SMTP_FROM:-}
- SMTP_FROM_NAME=${SMTP_FROM_NAME:-}
- SMTP_REPLY_TO=${SMTP_REPLY_TO:-}
- SMTP_SECURE=${SMTP_SECURE:-}
# Uncomment to enable Redis (optional — used for response caching and rate limiting)
# - REDIS_URL=redis://redis:6379
# Deutsche Bahn connector: URL of a MOTIS instance. Set together with
# COMPOSE_PROFILES=motis to run the bundled one (see deploy/motis); the
# adapter then fills its MOTIS_URL in automatically at import. Leave
# unset to be asked for a URL when installing the adapter.
- MOTIS_INTERNAL_URL=${MOTIS_INTERNAL_URL:-}
# TikTok Shop server app: TikTok Shop connectors without an App key of
# their own use it (see .env.example). Unset = each connector needs the
# seller's own app.
- TIKTOK_SHOP_PLATFORM_APP_KEY=${TIKTOK_SHOP_PLATFORM_APP_KEY:-}
- TIKTOK_SHOP_PLATFORM_APP_SECRET=${TIKTOK_SHOP_PLATFORM_APP_SECRET:-}
- TIKTOK_SHOP_PLATFORM_SERVICE_ID=${TIKTOK_SHOP_PLATFORM_SERVICE_ID:-}
# WooCommerce one-click key: off unless set to true (see .env.example).
- WOOCOMMERCE_ONE_CLICK=${WOOCOMMERCE_ONE_CLICK:-}
- META_PLATFORM_APP_ID=${META_PLATFORM_APP_ID:-}
- META_PLATFORM_APP_SECRET=${META_PLATFORM_APP_SECRET:-}
- META_PLATFORM_CONFIG_ID=${META_PLATFORM_CONFIG_ID:-}
- META_PLATFORM_ORG_IDS=${META_PLATFORM_ORG_IDS:-}
# One-tap Telegram bot: off unless the manager bot's token is set (see .env.example).
- TELEGRAM_MANAGER_BOT_TOKEN=${TELEGRAM_MANAGER_BOT_TOKEN:-}
- TELEGRAM_MANAGER_WEBHOOK_SECRET=${TELEGRAM_MANAGER_WEBHOOK_SECRET:-}
- TELEGRAM_MANAGED_BOT_ORG_IDS=${TELEGRAM_MANAGED_BOT_ORG_IDS:-}
# Code mode: WebSocket URL of the code-runner service that executes code
# runs in isolation (see deploy/code-runner/README.md). Empty = code mode
# off, the default. Set together with COMPOSE_PROFILES=code-runner to run
# the bundled runner: CODE_RUNNER_URL=ws://code-runner:8777. The backend
# never runs code in-process; an unset or unreachable runner means code
# runs are refused, not executed locally.
- CODE_RUNNER_URL=${CODE_RUNNER_URL:-}
# Hosts the SSRF guard may reach even though they resolve to a private
# address. Needed for the bundled MOTIS (`motis`) and any other API you
# run on the same Docker network.
- SSRF_ALLOWED_HOSTS=${SSRF_ALLOWED_HOSTS:-}
# Largest upstream response one tool call reads, in bytes. Empty = the
# default, 10 MB (see .env.example).
- TOOL_MAX_RESPONSE_BYTES=${TOOL_MAX_RESPONSE_BYTES:-}
# Public IPs this server calls APIs from, shown to users who must
# allowlist them (see .env.example). Empty = not shown.
- EGRESS_IPS=${EGRESS_IPS:-}
# Knowledge Graph LLM (optional): hosted providers need their API key,
# a local OpenAI-compatible endpoint needs KG_LLM_BASE_URL and no key
# (KG_LLM_API_KEY is only sent when set). From inside this container
# `localhost` is the app itself — point at the host or a sibling
# service instead, e.g. http://host.docker.internal:11434/v1
# (Linux: extra_hosts: ["host.docker.internal:host-gateway"]).
- KG_LLM_ENABLED=${KG_LLM_ENABLED:-}
- KG_LLM_PROVIDER=${KG_LLM_PROVIDER:-}
- KG_LLM_MODEL=${KG_LLM_MODEL:-}
- KG_LLM_BASE_URL=${KG_LLM_BASE_URL:-}
- KG_LLM_API_KEY=${KG_LLM_API_KEY:-}
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
# Prometheus /metrics — a separate listener, off by default (docs/operations/observability.md).
# METRICS_TOKEN is required once METRICS_ENABLED=true; the listener refuses to start without it.
- METRICS_ENABLED=${METRICS_ENABLED:-false}
- METRICS_PORT=${METRICS_PORT:-9464}
- METRICS_HOST=${METRICS_HOST:-0.0.0.0}
- METRICS_TOKEN=${METRICS_TOKEN:-}
- METRICS_TOOL_LABELS=${METRICS_TOOL_LABELS:-false}
# File Search (#1379), off unless the `files` profile runs: the internal
# address and token of files-worker, which does every sync and every
# connection to a file server. See docs/connectors/file-search.md.
- FILES_WORKER_URL=${FILES_WORKER_URL:-}
- FILES_WORKER_TOKEN=${FILES_WORKER_TOKEN:-}
# Folders mounted into this install that File Search may read
# (comma-separated, absolute). Mount them read-only into app AND files-worker.
- FILE_SOURCE_ROOTS=${FILE_SOURCE_ROOTS:-}
- FILES_MAX_FILE_BYTES=${FILES_MAX_FILE_BYTES:-}
# File Share storage: a volume by default (/data/files), or S3.
- FILES_STORAGE=${FILES_STORAGE:-local}
- FILES_STORAGE_DIR=/data/files
- FILES_S3_ENDPOINT=${FILES_S3_ENDPOINT:-}
- FILES_S3_REGION=${FILES_S3_REGION:-}
- FILES_S3_BUCKET=${FILES_S3_BUCKET:-}
- FILES_S3_ACCESS_KEY_ID=${FILES_S3_ACCESS_KEY_ID:-}
- FILES_S3_SECRET_ACCESS_KEY=${FILES_S3_SECRET_ACCESS_KEY:-}
- FILES_DOWNLOAD_BASE_URL=${FILES_DOWNLOAD_BASE_URL:-}
volumes:
- file_share_data:/data/files
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:4000/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: unless-stopped
# PostgreSQL Database
postgres:
image: postgres:17-alpine
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-postgres
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=amcp
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-amcp}
- POSTGRES_DB=anythingmcp
healthcheck:
test: ["CMD-SHELL", "pg_isready -U amcp -d anythingmcp"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
# MOTIS routing engine for the Deutsche Bahn connector (optional).
# Activated by COMPOSE_PROFILES=motis in .env, together with
# MOTIS_INTERNAL_URL=http://motis:8080 and SSRF_ALLOWED_HOSTS=motis. Pulls
# the open gtfs.de train timetable on first boot and refreshes it weekly;
# about 12 MB of GTFS, a one-second import, ~100 MB of RAM at rest.
# Details and feed licences: deploy/motis/README.md
motis:
build:
context: ./deploy/motis
image: anythingmcp-motis:2.11.3-1
profiles: ["motis"]
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-motis
volumes:
- motis_data:/data
healthcheck:
# 127.0.0.1, not localhost: MOTIS binds IPv4 only and localhost resolves
# to ::1 first inside the container, so the probe was refused every time.
# /metrics, not /: MOTIS answers 404 on the root, which --spider treats as
# a failure. Between the two, the container reported unhealthy for its
# whole life while serving traffic perfectly.
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1:8080/metrics"]
interval: 30s
timeout: 5s
retries: 3
start_period: 180s
restart: unless-stopped
# Code-runner for code mode (optional). Activated by
# COMPOSE_PROFILES=code-runner in .env, together with
# CODE_RUNNER_URL=ws://code-runner:8777 on the app. Executes code-mode runs in
# isolation: a Deno subprocess per run under an unprivileged uid, every
# permission denied, no filesystem, no environment, and no egress — the only
# way out is the MCP tools the caller already has. Full model and the
# containment test: deploy/code-runner/README.md. No ports are published: the
# app reaches it by service name on the internal network only.
code-runner:
build:
context: ./deploy/code-runner
image: anythingmcp-code-runner:1
profiles: ["code-runner"]
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-code-runner
# The runner holds no secrets and needs no inbound internet. Bounded so a
# runaway run cannot starve the host; a per-run V8 heap cap and wall-clock
# deadline are enforced inside the supervisor as well.
mem_limit: ${CODE_RUNNER_MEM_LIMIT:-1g}
cpus: ${CODE_RUNNER_CPUS:-1.0}
pids_limit: 512
read_only: true
tmpfs:
- /tmp/code-runner:mode=1777
security_opt:
# Dropping privileges with setpriv is always allowed; this only blocks
# GAINING them (setuid binaries), which the runner never needs to.
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
# setpriv needs these to change the child's uid/gid; nothing else is kept.
- SETUID
- SETGID
healthcheck:
test: ["CMD", "deno", "eval", "const r = await fetch('http://127.0.0.1:8777'); Deno.exit(r.ok ? 0 : 1)"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
restart: unless-stopped
# File Search (#1379, AnythingMCP Commercial License, ee/): enable with
# COMPOSE_PROFILES=files and set FILES_WORKER_URL=http://files-worker:8891,
# FILES_WORKER_TOKEN and FILE_EXTRACTOR_TOKEN (each: openssl rand -hex 24).
# Needs a paid licence or the 30-day trial. The worker does every sync and
# every connection to a file server, so a slow server or a big first sync
# never slows down the MCP endpoint in `app`.
files-worker:
image: helpcodeai/anythingmcp:latest
profiles: ["files"]
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-files-worker
command: ["./start.sh", "files-worker"]
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://amcp:${POSTGRES_PASSWORD:-amcp}@postgres:5432/anythingmcp
- JWT_SECRET=${JWT_SECRET:-change-me-in-production-min-32-chars}
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-change-me-in-production-exactly-32}
- DEPLOYMENT_MODE=${DEPLOYMENT_MODE:-}
- FILES_WORKER_TOKEN=${FILES_WORKER_TOKEN:-}
- FILES_WORKER_HOST=0.0.0.0
- FILES_WORKER_PORT=8891
- FILES_WORKER_MAX_OLD_SPACE_MB=${FILES_WORKER_MAX_OLD_SPACE_MB:-512}
- FILES_WORKER_CONCURRENCY=${FILES_WORKER_CONCURRENCY:-2}
- FILE_EXTRACTOR_URL=http://file-extractor:8890
- FILE_EXTRACTOR_TOKEN=${FILE_EXTRACTOR_TOKEN:-}
- FILE_SOURCE_ROOTS=${FILE_SOURCE_ROOTS:-}
- FILES_MAX_FILE_BYTES=${FILES_MAX_FILE_BYTES:-}
- FILES_STORAGE=${FILES_STORAGE:-local}
- FILES_STORAGE_DIR=/data/files
- FILES_S3_ENDPOINT=${FILES_S3_ENDPOINT:-}
- FILES_S3_REGION=${FILES_S3_REGION:-}
- FILES_S3_BUCKET=${FILES_S3_BUCKET:-}
- FILES_S3_ACCESS_KEY_ID=${FILES_S3_ACCESS_KEY_ID:-}
- FILES_S3_SECRET_ACCESS_KEY=${FILES_S3_SECRET_ACCESS_KEY:-}
- SSRF_ALLOWED_HOSTS=${SSRF_ALLOWED_HOSTS:-}
- KG_LLM_ENABLED=${KG_LLM_ENABLED:-}
- KG_LLM_PROVIDER=${KG_LLM_PROVIDER:-}
- KG_LLM_MODEL=${KG_LLM_MODEL:-}
- KG_LLM_BASE_URL=${KG_LLM_BASE_URL:-}
- KG_LLM_API_KEY=${KG_LLM_API_KEY:-}
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
volumes:
- file_share_data:/data/files
# Network folders: mount the share on the host, then bind it read-only
# here and in `app`, and list it in FILE_SOURCE_ROOTS, e.g.
# - /mnt/knowledge:/mnt/knowledge:ro
networks: [default, files_internal]
mem_limit: ${FILES_WORKER_MEM_LIMIT:-1g}
cpus: ${FILES_WORKER_CPUS:-1.0}
depends_on:
postgres:
condition: service_healthy
app:
condition: service_healthy
# Lets a running slice finish and release its lease (scheduler waits 20 s).
stop_grace_period: 30s
# The image's own healthcheck probes the backend on :4000; the worker
# answers on its internal port.
healthcheck:
test: ["CMD-SHELL", "wget --quiet --tries=1 -O /dev/null --header \"X-Worker-Token: $${FILES_WORKER_TOKEN}\" http://127.0.0.1:8891/internal/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 60s
restart: unless-stopped
# Text extraction for File Search (ee/): no route to the internet, no
# database, no secrets. Reached only by files-worker on files_internal.
# deploy/ee/file-extractor/README.md describes the formats and limits.
file-extractor:
build:
context: ./deploy/ee/file-extractor
image: anythingmcp-file-extractor:4
profiles: ["files"]
container_name: ${COMPOSE_PROJECT_NAME:-amcp}-file-extractor
environment:
- EXTRACTOR_TOKEN=${FILE_EXTRACTOR_TOKEN:-}
networks: [files_internal]
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
mem_limit: ${FILE_EXTRACTOR_MEM_LIMIT:-2g}
cpus: ${FILE_EXTRACTOR_CPUS:-1.0}
pids_limit: 128
restart: unless-stopped
# Redis Cache (optional — uncomment to enable response caching and rate limiting)
# redis:
# image: redis:7-alpine
# container_name: ${COMPOSE_PROJECT_NAME:-amcp}-redis
# volumes:
# - redis_data:/data
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 5s
# timeout: 3s
# retries: 5
# restart: unless-stopped
volumes:
postgres_data:
motis_data: # Imported timetable for the optional MOTIS service
caddy_data: # Let's Encrypt certificates (used when Caddy proxy is enabled)
caddy_config: # Caddy configuration cache
# redis_data: # Uncomment if Redis is enabled
file_share_data: # File Share links (File Search, `files` profile)
networks:
# No route out: the text extractor parses untrusted files and must not be
# able to reach anything but files-worker.
files_internal:
internal: true