Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
132 lines (126 loc) · 6.24 KB
/
Copy pathdocker-compose.yml
File metadata and controls
132 lines (126 loc) · 6.24 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
services:
imagentj:
image: ${IMAGENTJ_IMAGE:-agenticj:cpu-local-napari}
# Do not pin platform here: Docker/BuildKit builds for the host architecture
# by default, and the Dockerfile routes arch-specific steps via TARGETARCH.
build:
context: .
dockerfile: ${IMAGENTJ_DOCKERFILE:-Dockerfile}
target: cpu
ports:
# Bind to localhost only by default for security
# Change to "0.0.0.0:6080:6080" if you need network access (not recommended)
- "0.0.0.0:6080:6080"
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY:-}
- FIJI_PATH=/opt/Fiji.app
- QDRANT_DATA_PATH=/app/qdrant_data
# ── Generic MCP host: in-container napari-mcp stdio server ────────────
# The supervisor discovers napari tools at startup (no napari window yet);
# the viewer opens lazily on the first napari tool call. Timeouts are
# generous because that first call spins up napari + software GL.
- IMAGENTJ_MCP_CONFIG=${IMAGENTJ_MCP_CONFIG:-/app/.imagentj/mcp.json}
- IMAGENTJ_MCP_CONFIG_JSON=${IMAGENTJ_MCP_CONFIG_JSON:-}
- IMAGENTJ_MCP_DISCOVERY_TIMEOUT_SECONDS=${IMAGENTJ_MCP_DISCOVERY_TIMEOUT_SECONDS:-20}
- IMAGENTJ_MCP_TOOL_TIMEOUT_SECONDS=${IMAGENTJ_MCP_TOOL_TIMEOUT_SECONDS:-90}
- IMAGENTJ_MCP_KEEP_ALIVE=${IMAGENTJ_MCP_KEEP_ALIVE:-true}
# Hard per-message backstop for tool results sent to an LLM. Individual
# tools use smaller semantic limits where appropriate.
- IMAGENTJ_MAX_TOOL_OUTPUT_CHARS=${IMAGENTJ_MAX_TOOL_OUTPUT_CHARS:-100000}
- DISPLAY=:1
# Optional: Set a VNC password (recommended if exposing to network)
- VNC_PASSWORD=${VNC_PASSWORD:-}
- PYTHONPATH=/app:/app/src
- PYTHONUNBUFFERED=1
volumes:
# Fiji plugin persistence — seeded from image on first run by entrypoint
- fiji_plugins:/opt/Fiji.app/plugins
- fiji_jars:/opt/Fiji.app/jars
# DeepImageJ APPOSE framework environments (TF, PyTorch) — persisted so
# they are created once on first model run and reused on every subsequent start
- appose_envs:/opt/appose
# Saved scripts persistence
- saved_scripts:/app/scripts/saved_scripts
# Qdrant vector database for plugin search and RAG.
# Bind-mount the host folder directly: qdrant_data/ is in .dockerignore and therefore
# never reaches the image, so a named volume would always seed empty. The host folder
# is the source of truth for ingested data.
- ./qdrant_data:/app/qdrant_data
# Image data directory (place images in ./data on host, access as /mnt/data in container)
- ${IMAGE_DATA_DIR:-./data}:/data
# Source code mount for development (remove in production image)
- ./src:/app/src:ro
# MCP host config (mcpServers) — analogous to Claude Code's config.
# Edit .imagentj/mcp.json to add/disable MCP servers without rebuilding.
- ./.imagentj:/app/.imagentj:ro
- ./gui_runner.py:/app/gui_runner.py:ro
- ./setup_wizard.py:/app/setup_wizard.py:ro
# Runtime config (LLM per role + Vision/QA switches). Edit on the host and
# it takes effect next run — no rebuild. See imagentj_config.yaml.
- ./imagentj_config.yaml:/app/imagentj_config.yaml:ro
# Folder to save data. The benchmark adapter sets IMAGENTJ_APP_DATA_DIR to a
# per-run mkdtemp so parallel benchmark runs do not see each other's
# projects; without it the shared ./data checkout leaks old artifacts into
# the collector.
- ${IMAGENTJ_APP_DATA_DIR:-./data}:/app/data
# User home — persists api_keys.env (outside /app/data so agent can't read it)
- imagentj_home:/home/imagentj
# Cellpose models — named volume seeded from models baked into the image.
# Models are downloaded from cloud storage during docker build and stored
# in /home/imagentj/.cellpose/models inside the image; the named volume
# seeds from there on first start and persists downloaded models across restarts.
- cellpose_models:/home/imagentj/.cellpose/models
# Folder for skills
- ./skills:/app/skills:ro
# Entrypoint bind-mount so changes take effect without rebuilding
- ./docker-entrypoint.sh:/docker-entrypoint.sh:ro
# Shim bind-mounts — host file is executable; avoids needing root chmod after cp
- ./micromamba_shim.sh:/usr/local/opt/micromamba/bin/micromamba:ro
- ./micromamba_shim.sh:/opt/micromamba/bin/micromamba:ro
env_file:
- path: .env
required: false
shm_size: '2gb'
networks:
- imagent_net
# ── Resource limits ────────────────────────────────────────────────────
# memory: the JVM heaps are derived from THIS number at startup
# (imagej_context._default_heap_gb takes half for the app JVM,
# script_tools._batch_env a quarter for the batch worker), so raising it
# raises them and lowering it lowers them — no separate tuning needed.
# 8G -> 4 g app + 2 g batch (was OOM-killing the container at 6 g + 2 g)
# 12G -> 6 g app + 3 g batch (fits a 4-channel 8x8 mosaic stitch)
# 64G -> 32 g app + 16 g batch <- current
# Keep headroom on the host: this is a limit, not a reservation, but the
# kernel will OOM-kill the container if the host itself runs out.
deploy:
resources:
limits:
cpus: '4'
memory: 64G
reservations:
memory: 2G
# ── Security hardening ──────────────────────────────────────────────────
# Run as non-root (also set in Dockerfile, belt-and-suspenders)
user: "imagentj"
# Prevent privilege escalation
security_opt:
- no-new-privileges:true
# Drop all Linux capabilities — none are needed
cap_drop:
- ALL
volumes:
fiji_plugins:
fiji_jars:
saved_scripts:
appose_envs:
imagentj_home:
cellpose_models:
networks:
imagent_net:
ipam:
driver: default
config:
# Using 10.10.10.0/24 is usually safe from 172.x conflicts
- subnet: ${IMAGENTJ_SUBNET:-10.10.10.0/24}