-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
127 lines (123 loc) · 6.11 KB
/
Copy pathdocker-compose.yml
File metadata and controls
127 lines (123 loc) · 6.11 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
services:
codebadger-joern-server:
build:
context: .
dockerfile: Dockerfile
image: codebadger-joern-server:latest
container_name: codebadger-joern-server
ports:
# Bind to loopback only. Each Joern server runs the full Ammonite Scala
# REPL with no auth by default, so publishing this range on all interfaces
# would expose unauthenticated code execution that bypasses the MCP's CPGQL
# validation. The MCP reaches these via localhost (host networking). Pool
# worker containers already publish on 127.0.0.1 (see joern_server_manager).
- "127.0.0.1:13371-13870:13371-13870"
volumes:
# Same host dir the MCP mounts; keep PLAYGROUND_HOST_PATH consistent across services.
- ${PLAYGROUND_HOST_PATH:-./playground}:/playground
restart: unless-stopped
mem_limit: ${JOERN_MEM_LIMIT:-100g}
# The MCP server. Drives the host Docker daemon (socket mount) to build CPGs in
# codebadger-joern-server and to spawn per-CPG pool worker containers; uses host
# networking so the existing localhost:<published-port> wiring (Joern servers,
# Postgres, Redis, and its own :4242) all works unchanged. Starts with the full
# stack by default. For deps-only / run-MCP-on-host dev, add
# `--scale codebadger-mcp=0`.
codebadger-mcp:
build:
context: .
dockerfile: Dockerfile.mcp
image: codebadger-mcp:latest
container_name: codebadger-mcp
network_mode: host
volumes:
# MUST be the SAME host dir joern-server mounts at /playground. PLAYGROUND_HOST_PATH
# must be ABSOLUTE so pool worker containers (started via the host daemon) bind
# the right source — scripts/deploy.sh sets it. The MCP derives its playground
# dir from the app location, so it mounts at /app/playground.
- ${PLAYGROUND_HOST_PATH:-./playground}:/app/playground
# Host daemon socket. Override DOCKER_SOCK (scripts/deploy.sh derives it from
# DOCKER_HOST) for a rootless / non-default socket; container side stays fixed.
- ${DOCKER_SOCK:-/var/run/docker.sock}:/var/run/docker.sock
- ./logs:/app/logs
environment:
# 0.0.0.0 = reachable on all interfaces. Set MCP_HOST=127.0.0.1 to bind
# loopback only (e.g. when a reverse proxy / socat already fronts it).
MCP_HOST: ${MCP_HOST:-0.0.0.0}
JOERN_WORKER_MODE: pool
JOERN_PLAYGROUND_HOST_PATH: ${PLAYGROUND_HOST_PATH:-./playground}
DATABASE_URL: postgresql://codebadger:codebadger@localhost:${POSTGRES_PORT:-55432}/codebadger
REDIS_URL: redis://localhost:${REDIS_PORT:-56379}/0
CPG_QUEUE_BACKEND: ${CPG_QUEUE_BACKEND:-durable}
# Large-project guard: set CPG_LARGE_PROJECT_GUARD=false for unattended/batch
# drivers that always intend to build (they can't pass force=True per call).
CPG_LARGE_PROJECT_GUARD: ${CPG_LARGE_PROJECT_GUARD:-true}
CPG_LARGE_PROJECT_MAX_MB: ${CPG_LARGE_PROJECT_MAX_MB:-2000}
CPG_LARGE_PROJECT_MAX_LOC: ${CPG_LARGE_PROJECT_MAX_LOC:-2000000}
# Memory sizing — run scripts/recommend_config.py for your host. JOERN_MEM_LIMIT
# MUST match the joern-server build cap below so the MCP's over-commit guard
# leaves the right amount for the query-worker pool. 0 = auto-derive the budget.
JOERN_MEM_LIMIT: ${JOERN_MEM_LIMIT:-100g}
JOERN_MEMORY_BUDGET_MB: ${JOERN_MEMORY_BUDGET_MB:-0}
# Build sizing — fewer concurrent builds with a larger per-build c2cpg heap so
# large C/C++ projects don't OOM. CPG_BUILD_WORKERS * CPG_BUILD_HEAP_GB must
# stay <= JOERN_MEM_LIMIT (the build container's cap).
CPG_BUILD_WORKERS: ${CPG_BUILD_WORKERS:-4}
CPG_BUILD_HEAP_GB: ${CPG_BUILD_HEAP_GB:-6}
# Scale knobs: HTTP in-flight cap (503 past this) and the pre-build repo-size cap.
MAX_MCP_CONNECTIONS: ${MAX_MCP_CONNECTIONS:-16}
MAX_REPO_SIZE_MB: ${MAX_REPO_SIZE_MB:-1024}
# Port the MCP binds (host networking, so this is also the host port).
MCP_PORT: ${MCP_PORT:-4242}
# Pending CPG-build queue depth, independent of build concurrency. Too small
# and a high-concurrency client gets ~30% of generations rejected (queue_full).
CPG_QUEUE_MAXSIZE: ${CPG_QUEUE_MAXSIZE:-64}
# Security posture. CHAT_DEPLOY=true DISABLES source_type='local' so a
# chat-facing MCP can't read arbitrary host paths (callers use a github.com/
# gitlab.com URL or a pasted snippet). ALLOWED_SOURCE_ROOTS optionally
# hard-contains local sources to the given ':'-separated dirs AS SEEN INSIDE
# this container — local sources live under /app/playground here.
CHAT_DEPLOY: ${CHAT_DEPLOY:-false}
ALLOWED_SOURCE_ROOTS: ${ALLOWED_SOURCE_ROOTS:-}
depends_on:
codebadger-postgres:
condition: service_healthy
codebadger-redis:
condition: service_healthy
codebadger-joern-server:
condition: service_started
restart: unless-stopped
# Postgres and Redis are the backing services and start by default with
# `docker compose up -d`. CodeBadger fails to boot if they're unreachable.
codebadger-postgres:
image: postgres:16
container_name: codebadger-postgres
environment:
POSTGRES_USER: codebadger
POSTGRES_PASSWORD: codebadger
POSTGRES_DB: codebadger
ports:
# Non-default host port (override POSTGRES_PORT) to avoid clashing with a system Postgres.
- "127.0.0.1:${POSTGRES_PORT:-55432}:5432"
volumes:
# Kept OUTSIDE ./playground so the Joern containers (which mount the whole
# playground) can never read or corrupt the database files. See docs/security.md.
- ${POSTGRES_DATA_PATH:-./pgdata}:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U codebadger -d codebadger"]
interval: 10s
timeout: 5s
retries: 5
codebadger-redis:
image: redis:7
container_name: codebadger-redis
ports:
# Non-default host port (override REDIS_PORT) to avoid clashing with a system Redis.
- "127.0.0.1:${REDIS_PORT:-56379}:6379"
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5