-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
151 lines (146 loc) · 7.14 KB
/
Copy pathdocker-compose.yml
File metadata and controls
151 lines (146 loc) · 7.14 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
services:
codebadger-joern-server:
build:
context: .
dockerfile: Dockerfile
image: codebadger-joern-server:latest
container_name: codebadger-joern-server
ports:
# Bind to loopback only for external/debug access. In pool mode the MCP
# spawns per-CPG worker containers (same image) and reaches them via
# host.docker.internal. In shared mode the MCP connects via the Docker
# bridge network using the service name, so host-port publishing is only
# needed if you want to reach joern directly from the host for debugging.
- "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
networks:
- codebadger
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 a
# named bridge network for Postgres and Redis (via service-name DNS) and
# host.docker.internal for pool workers (spawned outside this compose project).
# 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
ports:
# Host publish for the MCP. MCP_PORT (default 4242, from .env) sets BOTH the
# in-container listen port and the host port. MCP_PUBLISH_HOST is the HOST
# interface the port is published on — default 127.0.0.1 (loopback only =
# the safe default; the MCP can drive the Docker daemon and read local
# sources, so do not expose it casually). Set MCP_PUBLISH_HOST=0.0.0.0 (or a
# specific host IP) to reach it from other machines. NOTE: this is the HOST
# bind, distinct from MCP_HOST (the in-container bind, which stays 0.0.0.0 so
# the published mapping can reach the app).
- "${MCP_PUBLISH_HOST:-127.0.0.1}:${MCP_PORT:-4242}:${MCP_PORT:-4242}"
networks:
- codebadger
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@codebadger-postgres:5432/codebadger
REDIS_URL: redis://codebadger-redis:6379/0
# Pool workers are attached to this network and reached by container name —
# no host port is published, so 127.0.0.1 binding is not needed anywhere.
JOERN_DOCKER_NETWORK: codebadger
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 (also the host port, matched by the ports: mapping above).
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
networks:
- codebadger
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"
networks:
- codebadger
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
codebadger:
name: codebadger