Repository navigation
Expand file tree
/
Copy pathdocker-compose-local.yml
More file actions
369 lines (358 loc) · 16.8 KB
/
Copy pathdocker-compose-local.yml
File metadata and controls
369 lines (358 loc) · 16.8 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
services:
trex:
# The -devx variant: same d2e layer as docker-compose.yml's image, but built
# on trexsql's full base, which carries playwright + chromium, the Claude
# Code CLI, gh and the devx payload (~1.2GB compressed). docker-compose.yml
# runs the lean one — TREX_DX_ENABLED only gates that tooling at runtime, so
# keeping it out of deployments needs a different image, not a flag.
# Set TREX_IMAGE (e.g. d2e-trex:withr in .env.local) to keep a locally built
# R+HADES image under its own tag, where pulling a published one would
# otherwise overwrite it with an R-less build.
image: ${TREX_IMAGE:-${DOCKER_IMAGE_PREFIX:-ghcr.io/ohdsi/}d2e-trex:${DOCKER_TAG_NAME:-develop}-devx}
# No platform pin: the trexsql base and d2e-trex image are multi-arch
# (amd64/arm64), so Docker runs/builds native to the host.
entrypoint: ["/bin/sh", "-c"]
command:
- |
mkdir -p /usr/src/cert
printf '%s' "$$TLS__INTERNAL__CRT" > /usr/src/cert/cert.pem
(umask 077; printf '%s' "$$TLS__INTERNAL__KEY" > /usr/src/cert/key.pem)
printf '%s' "$$TLS__INTERNAL__CA_CRT" > /usr/src/cert/ca.pem
cp /usr/src/cert/ca.pem /usr/local/share/ca-certificates/d2e-internal-ca.crt
update-ca-certificates
mkdir -p /usr/src/data/flow_staging && chmod 1777 /usr/src/data/flow_staging || exit 1
if [ "$${TREX_DX_ENABLED:-}" = "true" ] && [ -n "$${TREX_ROOT_KEY:-}" ]; then
mkdir -p /trex-secrets
printf 'TREX_ROOT_KEY=%s\n' "$$TREX_ROOT_KEY" > /trex-secrets/root.env
TREX_SECRETS_DIR=/trex-secrets /usr/local/bin/trex-init || echo "[dx] trex-init failed; DevX REST may 401"
set -a; . /trex-secrets/derived.env 2>/dev/null || true; set +a
fi
# This command replaces the image's own CMD, so the --enable-otel flag
# from Dockerfile.v2 never runs here; it must be re-added to this exec.
exec /usr/src/entrypoint.sh $${TREX_OTEL_ENABLED:+--enable-otel}
build:
context: ./services/trex
dockerfile: ./Dockerfile.v2
# GitHub Packages token for installing @ohdsi/* plugins (the Pythia agent).
secrets:
- github_token
args:
# Match the -devx image name above: without this a local build would use
# Dockerfile.v2's default (the lean prod base) and quietly produce an
# image with no devx tooling under a -devx tag.
#
# The second of the two TREXSQL_REF pins; the other is the ARG default
# in services/trex/Dockerfile.v2. Shipping trex code means bumping both.
# See docs/trex-oidc-provider-cutover.md.
TREXSQL_REF: ${TREXSQL_REF:-sha-974c584da03f996441dfe07549f94b4005066784@sha256:38041ff0d775185ee9a0e87e7a1d23a5e9b616edacca4f0c2a7412c68c304c9e}
# Local builds pull published plugins from the feed; CI uses plugin-artifacts/.
PLUGINS_FROM_REGISTRY: ${PLUGINS_FROM_REGISTRY:-@data2evidence/d2e-ui @data2evidence/d2e-functions @data2evidence/fhir @data2evidence/sibyl @data2evidence/d2e-flows @data2evidence/i2b2-flow @data2evidence/search-embedding-flow @data2evidence/data-management-flow @data2evidence/hades-flow @data2evidence/loyalty-score-flow @data2evidence/cohort-discovery-flow @data2evidence/eq5d5l-index-calculation-flow @data2evidence/data-transformation-flow @ohdsi/pythia-agent@0.1.0-develop.21.g24eb709}
# Keep in sync with the `docker build --build-arg WITH_R=true` used to
# produce the d2e-trex:withr tag above — `docker compose build trex`
# must also bake R or it silently reverts to an R-less image.
WITH_R: "true"
extra_hosts:
- "physionet-host:host-gateway"
networks:
alp:
aliases:
- ${PROJECT_NAME:-alp}-trex.${TLS__INTERNAL__DOMAIN:-d2e.local}
ports:
- 9229:9229
- 25432:5432
- 25433:5433
- 33000:33000
- 8094:8094
volumes:
- trex:/usr/src/data # Persist plugins and cache data - must match PLUGINS_PATH
- flows-dev:/usr/src/flows-dev
- devx-workspaces:/tmp/devx-workspaces
- trex-secrets:/trex-secrets
- trex-dx:/root/.claude
- trex-dx:/home/node/.claude
- trex-dx-gh:/root/.config/gh
- ${D2E_FUNCTIONS:-./plugins/functions}:/usr/src/plugins/d2ef
# PLUGINS_DEV_PATH resolves /usr/src/bundled-plugins before /usr/src/plugins,
# so the registry-published d2e-functions there (no /hades-api route) wins
# over the d2ef mount above unless overlaid directly.
- ${D2E_FUNCTIONS:-./plugins/functions}:/usr/src/bundled-plugins/d2e-functions
- ${D2E_FHIRFUNCTIONS:-./plugins/fhir_functions}:/usr/src/plugins/fhir
- ${D2E_SIBYLFUNCTIONS:-./plugins/sibyl_functions}:/usr/src/plugins/sibyl
- ./plugins/notebook_git:/usr/src/plugins/notebook-git
- ./plugins/atlas:/usr/src/plugins/atlas # Atlas UI plugin
# d2e's DB provisioning plugin, overlaid on the copy baked into the image so
# a source edit takes effect on restart without a rebuild. Local only: the
# CLI never stages this directory, so in docker-compose.yml the mount would
# hide the image's copy behind an empty one.
- ./services/trex/provision/d2e-bootstrap:/usr/src/bundled-plugins/d2e-bootstrap:ro
- studio-edge-functions:/app/edge-functions # shared with the studio sidecar (LOCAL ONLY)
# - ./plugins/chat_functions:/usr/src/plugins/chat
# - ./plugins/ui/package.json:/usr/src/plugins/d2e-ui/package.json # For local ui development only
# - ./plugins/ui/resources:/usr/src/plugins/d2e-ui/resources # For local ui development only
# - ./plugins/ui/resources:/usr/src/local-resources # For CI ui build mounting
# IMAGE-BASED TEST: no core source-mount — trex's main (now vendored into
# services/trex/core) is bundled into the image's eszip by Dockerfile.v2.
# - ./services/trex/deno.json:/usr/src/deno.json
# - ./plugins/flows/base/package.json:/usr/src/plugins/d2e-flows/package.json # For local flows development only
env_file:
- path: .env.claw
required: false
environment:
TREX_DX_ENABLED: "true"
# Enable trex's native email/password IDP for local dev (off by default in
# the engine). trex is the identity provider in every mode; this stays on.
TREX_IDP_ENABLED: "true"
IS_SANDBOX: "1"
BETTER_AUTH_URL: "https://localhost:${CADDY_PORT:-${PORT:-443}}/trex"
PGRST_DB_URI: postgres://authenticator:authenticator_pass@${PG_HOST:-${PROJECT_NAME:-d2e}-minerva-postgres-1}:${PG_PORT:-5432}/alp
PGRST_DB_SCHEMAS: public
PGRST_DB_ANON_ROLE: anon
PGRST_DB_PRE_REQUEST: public.postgrest_pre_request
PGRST_OPENAPI_SERVER_PROXY_URI: "https://localhost:${CADDY_PORT:-${PORT:-443}}/trex/rest/v1"
TREX_WEB_NAV_EXTRA: '[{"path":"/devx","label":"Code","plugin":"devx"}]'
DEVX_HOT_RELOAD: ${DEVX_HOT_RELOAD:-true}
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID:-}
DEVX_ENCRYPTION_KEY: ${DEVX_ENCRYPTION_KEY:-}
RUST_LOG: ${RUST_LOG:-info}
RUST_BACKTRACE: ${RUST_BACKTRACE:-full}
# Local dev defaults to exporting traces to the jaeger service below.
TREX_OTEL_ENABLED: ${TREX_OTEL_ENABLED:-true}
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://jaeger:4318}
OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-http/protobuf}
OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME:-trex}
LOCAL_DEBUG: "true"
DATABASE_CREDENTIALS: ${DATABASE_CREDENTIALS:-{}}
# Supabase Studio sidecar (LOCAL ONLY) — trex proxies /plugins/trex/studio/** to it.
STUDIO_INTERNAL_URL: http://${PROJECT_NAME:-d2e}-studio.${TLS__INTERNAL__DOMAIN:-d2e.local}:3000
EDGE_FUNCTIONS_MANAGEMENT_FOLDER: /app/edge-functions
# Bind-mounted source plugins win over bundled ones with the same package name.
# /usr/src/plugins-dev first so trex's own web/studio/notebook plugins load too.
PLUGINS_DEV_PATH: "/usr/src/plugins-dev:/usr/src/bundled-plugins:/usr/src/plugins"
SQL_QUERY_TEMPLATES: '{"cohort-members": "SELECT {{COHORT_ID}} AS cohort_id, CURRENT_TIMESTAMP AS exported_at", "patient-count": "SELECT COUNT(*) AS patient_count FROM {{SCHEMA}}.person"}'
# PhysioNet auto-provision / entitlements sync are OFF by default
USERMGMT__AUTO_PROVISION_CONNECTORS: ${USERMGMT__AUTO_PROVISION_CONNECTORS:-physionet}
USERMGMT__ENTITLEMENTS_PHYSIONET_BASE_URL: ${USERMGMT__ENTITLEMENTS_PHYSIONET_BASE_URL:-http://physionet-host:8000}
USERMGMT__ENTITLEMENTS_DATASET_MAPPING: '${USERMGMT__ENTITLEMENTS_DATASET_MAPPING:-{"demo":"demoeicu/1.0"}}'
SWARM_CONFIG: |-
{
"cluster_id": "d2e",
"nodes": {
"d2e": {
"gossip_addr": "0.0.0.0:4200",
"extensions": [
{
"name": "trexas",
"config": {
"host": "0.0.0.0",
"port": 33001,
"main_service_path": "/usr/src/core/server/index.eszip",
"event_worker_path": "/usr/src/core/event/index.eszip",
"tls_port": 33000,
"tls_cert_path": "/usr/src/cert/cert.pem",
"tls_key_path": "/usr/src/cert/key.pem",
"inspector": "inspect:0.0.0.0:9229"
}
},
{
"name": "pgwire",
"config": { "host": "0.0.0.0", "port": 5433, "password": "${TREX__SQL__PASSWORD:-pencil}" }
}
]
}
}
}
WATCH: |-
{
"analytics-svc": false,
"mri-pg-config": false,
"fhir-gateway": false,
"alp-dataflow-gen-init": false,
"query-gen-svc": false,
"alp-usermgmt": false,
"bookmark-svc": false,
"mri-pa-config": false,
"cdw-svc": false,
"jobplugins": false,
"dataset": false,
"alpdb": false,
"concept-mapping": false,
"terminology-svc": false,
"code-suggestion": false,
"data-mapping": false,
"portal": false,
"files-manager": false,
"demo": false,
"d2e-webapi": false,
"perseus": false,
"white-rabbit": false,
"strategus-analysis": false,
"mcp-server": false
}
alp-caddy:
ports:
- 41000:41000
- 41130:41130
environment:
CADDY__FHIR_SERVER__PUBLIC_FQDN: ${CADDY__FHIR_SERVER__PUBLIC_FQDN:-localhost}
CADDY__CORS_LOCAL_UI: "import cors"
alp-dataflow-gen:
build:
context: ./services/alp-dataflow-gen
dockerfile: Dockerfile
ports:
- 41120:41120
environment:
SYSTEM_PORTAL__API_URL: https://trex:33000/system-portal/
alp-dataflow-gen-worker:
build:
context: .
dockerfile: ./services/alp-dataflow-gen-worker/Dockerfile
secrets:
- github_pat
# flows-dev overlay: devx/trex writes flow source here, worker executes it.
# Local-dev only; inert unless D2E_FLOWS_DEV_DIR is set. See run-flow.sh.
volumes:
- flows-dev:/var/lib/d2e-flows-dev
environment:
D2E_FLOWS_DEV_DIR: ${D2E_FLOWS_DEV_DIR:-}
alp-logto:
build:
context: ./services/alp-logto
dockerfile: Dockerfile
extra_hosts:
- "physionet-host:host-gateway"
# volumes:
# Overlay the bundled connector-oidc with a d2e-patched version that
# writes the upstream access/refresh tokens to globalThis.tokenMap so the
# Logto JWT customizer can surface them as physionet_access_token /
# physionet_refresh_token claims. Mirrors the connector-alp-azuread
# override pattern below.
# - ./services/alp-logto/connector-oidc-patched/lib:/etc/logto/packages/connectors/connector-oidc/lib
# - ./services/alp-logto/connector-alp-azuread/lib:/etc/logto/packages/connectors/connector-alp-azuread/lib
alp-minerva-postgres:
ports:
- 41190:5432
# - 5432:5432 # 41190 already exposes it; avoids clashing with other local stacks
demodb:
ports:
- "15432:5432"
alp-logto-post-init:
build:
context: ./services/alp-logto/post-init
dockerfile: Dockerfile
# volumes:
# - ./services/alp-logto/post-init:/home/docker
materialize-cohorts:
profiles:
- materialize-cohorts
networks:
alp:
priority: 20
command: npm run start
hostname: ${PROJECT_NAME:-d2e}-materialize-cohorts
image: ${DOCKER_IMAGE_PREFIX:-ghcr.io/ohdsi/}d2e-materialize-cohorts:${DOCKER_TAG_NAME:-develop}
build:
context: .
dockerfile: ./services/materialize-cohorts/Dockerfile
volumes:
- services/materialize-cohorts/PKI/server.key:/app/PKI/server.key
- services/materialize-cohorts/PKI/server.crt:/app/PKI/server.crt
- services/materialize-cohorts/PKI/ca.crt:/app/PKI/ca.crt
environment:
PORT: 3333
INSTALL_SQLALCHEMY_HANA: ${INSTALL_SQLALCHEMY_HANA:-false}
API_MTLS_ENABLED: ${MATERIALIZE_COHORTS_API_MTLS_ENABLED:-true}
API_TLS_KEY_PATH: ${MATERIALIZE_COHORTS_API_TLS_KEY_PATH:-/app/PKI/server.key}
API_TLS_CERT_PATH: ${MATERIALIZE_COHORTS_API_TLS_CERT_PATH:-/app/PKI/server.crt}
API_TLS_CA_PATH: ${MATERIALIZE_COHORTS_API_TLS_CA_PATH:-/app/PKI/ca.crt}
healthcheck:
test: ["CMD-SHELL", "curl -fsSk https://127.0.0.1:3333/health"]
interval: 10s
timeout: 10s
retries: 3
start_period: 10s
# Jaeger UI for local trace inspection, on http://localhost:16686. Starts with
# the local stack because trex defaults to exporting traces here; gating it
# behind a profile would leave those exports pointing at nothing.
jaeger:
image: jaegertracing/all-in-one:1.62.0
networks:
alp:
environment:
COLLECTOR_OTLP_ENABLED: "true"
ports:
- 16686:16686
- 4317:4317
- 4318:4318
# trex studio sidecar — LOCAL ONLY (intentionally not in docker-compose.yml).
# Internal-only: no host port. trex proxies /plugins/trex/studio/** to it and
# enforces its own admin-only gate.
studio:
image: ghcr.io/ohdsi/trex-studio:latest
container_name: ${PROJECT_NAME:-d2e}-studio
hostname: ${PROJECT_NAME:-d2e}-studio.${TLS__INTERNAL__DOMAIN:-d2e.local}
restart: unless-stopped
networks:
alp:
aliases:
- studio
- ${PROJECT_NAME:-d2e}-studio.${TLS__INTERNAL__DOMAIN:-d2e.local}
depends_on:
trex:
condition: service_healthy
entrypoint: ["/bin/sh", "-c"]
command:
- |
for i in $$(seq 1 60); do [ -s /trex-secrets/derived.env ] && break; echo "[studio] waiting for /trex-secrets/derived.env ($$i)"; sleep 1; done
if [ -s /trex-secrets/derived.env ]; then set -a; . /trex-secrets/derived.env; set +a; else echo "[studio] WARN: derived.env missing; pg-meta will 500"; fi
exec /usr/local/bin/docker-entrypoint.sh node apps/studio/server.js
volumes:
- studio-snippets:/app/snippets
- studio-edge-functions:/app/edge-functions
# The baked key-fetch reads trex.setting; d2e stores auth keys in trexdb.setting.
- ./services/studio/fetch-trex-keys.cjs:/app/apps/studio/fetch-trex-keys.cjs:ro
- trex-secrets:/trex-secrets:ro
healthcheck:
test:
- CMD-SHELL
- 'node -e "fetch(''http://localhost:3000/plugins/trex/studio/api/platform/profile'').then(r => { if (r.status !== 200) throw new Error(r.status) })"'
interval: 10s
timeout: 5s
retries: 5
start_period: 60s
environment:
HOSTNAME: "0.0.0.0"
# trex serves the supabase-compat surface under /trex at its internal endpoint.
SUPABASE_URL: http://${PROJECT_NAME:-d2e}-trex.${TLS__INTERNAL__DOMAIN:-d2e.local}:33001/trex
SUPABASE_PUBLIC_URL: https://localhost:41100/trex
STUDIO_PG_META_URL: http://${PROJECT_NAME:-d2e}-trex.${TLS__INTERNAL__DOMAIN:-d2e.local}:33001/trex/pg/v1
SUPABASE_ANON_KEY: ${SUPABASE_ANON_KEY:-}
SUPABASE_SERVICE_KEY: ${SUPABASE_SERVICE_KEY:-}
# Fallback direct DB access — trexdb lives in the alp Postgres.
POSTGRES_HOST: ${PG_HOST:-${PROJECT_NAME:-d2e}-minerva-postgres-1}
POSTGRES_PORT: ${PG_PORT:-5432}
POSTGRES_DB: alp
POSTGRES_PASSWORD: ${PG_SUPER_PASSWORD}
POSTGRES_USER_READ_WRITE: ${PG_SUPER_USER:-postgres}
POSTGRES_USER_READ_ONLY: ${PG_SUPER_USER:-postgres}
PGRST_DB_SCHEMAS: public,storage
DEFAULT_ORGANIZATION_NAME: ${PROJECT_NAME:-d2e}
DEFAULT_PROJECT_NAME: default
NEXT_ANALYTICS_BACKEND_PROVIDER: postgres
NEXT_PUBLIC_ENABLE_LOGS: "false"
SNIPPETS_MANAGEMENT_FOLDER: /app/snippets
EDGE_FUNCTIONS_MANAGEMENT_FOLDER: /app/edge-functions
volumes:
flows-dev:
studio-snippets:
studio-edge-functions:
devx-workspaces:
trex-secrets:
trex-dx:
trex-dx-gh:
# Build-time GitHub Packages token for installing @ohdsi/* plugins.
secrets:
github_token:
environment: GITHUB_TOKEN
github_pat:
environment: GITHUB_PAT