Repository navigation
Expand file tree
/
Copy pathcompose.dev.yml
More file actions
696 lines (656 loc) · 38.1 KB
/
Copy pathcompose.dev.yml
File metadata and controls
696 lines (656 loc) · 38.1 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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
---
# Development environment for Mokosh Server.
# Usage: just dev (brings up the Traefik-routed stack; COMPOSE_FILE is
# compose.dev.yml). PMS-511 folded the former SSO overlay in here, so the
# Traefik-routed `*.a8n.run` stack is now the only dev stack.
#
# Naming convention (see ~/.claude/CLAUDE.md):
# - Project name `dev-mokosh-${USER}` (PMS-1281) namespaces every resource
# under the `dev-mokosh-` prefix in `docker ps`, `docker volume ls`, and
# `docker network ls`, AND is itself per-developer, so a `docker compose`
# command run by one developer never lists or removes another's resources
# (an unqualified project name previously let `just down` / `just
# dev-clean` treat another developer's network as an orphan of the same
# project). Service keys are short and descriptive (`server`, `infisical`,
# `infisical-postgres`, `valkey`) - they do not repeat the `mokosh` segment,
# since the project name already carries it.
# - `container_name:` is set explicitly on every service with the
# `dev-mokosh-{descriptive}-${USER}` shape so multiple developers can
# run their own dev stacks on a shared host without colliding on
# container/volume/network names. `USER` is injected into .env by
# `just dev` (captured via `whoami`).
# - Sub-services keep their parent's segment before the resource type, so
# the volume `dev-mokosh-infisical-postgres-data-${USER}` sorts
# adjacent to its parent in alphabetical listings.
#
# This stack contains the Mokosh API server plus its secrets-management
# infrastructure (Infisical + its Postgres + Valkey, behind the `infisical`
# profile). The Mokosh client apps run separately (see ../mokosh-apps) and
# reach the API through Traefik at https://${USER}-mokosh-api.a8n.run.
#
# The Mokosh API server runs as the `server` service, reachable inside the
# compose network as `server:${MOKOSH_PORT}`. It publishes no LAN-IP host
# port: the shared Traefik (on the external `traefik-public` network) is the
# sole ingress and terminates TLS via Let's Encrypt, routing
# https://${USER}-mokosh-api.a8n.run to the container's $MOKOSH_PORT (see the
# server's `labels` below).
#
# No service here publishes a host port on a LAN address, and none should:
# postgres and mailpit publish on loopback only (PMS-496), so host-side tooling
# (sqlx-cli, the mail UI) reaches them via localhost while the LAN/internet
# cannot, and the server is reachable through Traefik alone. The LAN-IP variable
# that once carried such a bind was removed in PMS-863 once nothing read it.
#
# The Mokosh application database runs inside this stack as the
# `postgres` service (separate from `infisical-postgres`, which is for
# Infisical only). Server reaches it via in-network DNS at
# `postgres:5432`. The container is also published to the host on
# loopback so host-side tools (sqlx-cli via `just migrate-run`) can
# connect via `127.0.0.1:${MOKOSH_PG_HOST_PORT}` (default 5433 to
# avoid clashing with any host-side postgres on 5432).
#
# This file contains no hardcoded values. Every environment variable is
# sourced from .env (which is generated from .env.example by `just dev`).
# Required-but-empty values use the `${VAR:?...}` form so compose fails
# loudly with a helpful message instead of starting a misconfigured stack.
# SPEC-10.133
name: dev-mokosh-${USER:?USER missing - run via just dev}
services:
# PostgreSQL database for Infisical (internal only).
# SPEC-10.134
infisical-postgres:
profiles: ["infisical"]
container_name: dev-mokosh-infisical-postgres-${USER:?USER missing - run via just dev}
# https://hub.docker.com/_/postgres
image: postgres:18.2-alpine3.23
environment:
POSTGRES_DB: ${INFISICAL_PG_DB:?INFISICAL_PG_DB missing - run `just dev` (which generates .env from .env.example)}
POSTGRES_USER: ${INFISICAL_PG_USER:?INFISICAL_PG_USER missing - run `just dev` (which generates .env from .env.example)}
POSTGRES_PASSWORD: ${INFISICAL_PG_PASSWORD:?INFISICAL_PG_PASSWORD missing - run `just dev` (which generates .env from .env.example)}
networks:
- private
expose:
- "5432"
volumes:
- infisical-postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 5
# Prefer Valkey over Redis (required by Infisical). Internal only.
# Only Infisical consumes Valkey, so gate it behind the same profile to
# keep it from starting when the infisical profile is not selected.
valkey:
profiles: ["infisical"]
container_name: dev-mokosh-valkey-${USER:?USER missing - run via just dev}
# https://hub.docker.com/r/valkey/valkey
image: docker.io/valkey/valkey:8-alpine
networks:
- private
expose:
- "6379"
healthcheck:
test: ["CMD", "valkey-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
# Infisical secrets manager (admin UI reachable from the host).
infisical:
profiles: ["infisical"]
container_name: dev-mokosh-infisical-${USER:?USER missing - run via just dev}
image: infisical/infisical:v0.161.0
environment:
ENCRYPTION_KEY: ${INFISICAL_ENCRYPTION_KEY:?INFISICAL_ENCRYPTION_KEY missing - run `just dev` (which generates .env from .env.example)}
AUTH_SECRET: ${INFISICAL_AUTH_SECRET:?INFISICAL_AUTH_SECRET missing - run `just dev` (which generates .env from .env.example)}
DB_CONNECTION_URI: ${INFISICAL_DB_CONNECTION_URI:?INFISICAL_DB_CONNECTION_URI missing - run `just dev` (which generates .env from .env.example)}
REDIS_URL: ${INFISICAL_REDIS_URL:?INFISICAL_REDIS_URL missing - run `just dev` (which generates .env from .env.example)}
SITE_URL: ${INFISICAL_SITE_URL:?INFISICAL_SITE_URL missing - run `just dev` (which generates .env from .env.example)}
TELEMETRY_ENABLED: ${INFISICAL_TELEMETRY_ENABLED:?INFISICAL_TELEMETRY_ENABLED missing - run `just dev` (which generates .env from .env.example)}
networks:
- private
ports:
# PMS-900: host side from .env, for the same reason as the others.
# Changing it means changing `INFISICAL_URL` and `INFISICAL_SITE_URL`
# in your .env to match: the bootstrap CLI reads the first from the
# host and Infisical builds its own links from the second, and neither
# can be derived from this line.
- "127.0.0.1:${MOKOSH_INFISICAL_HOST_PORT:-28002}:8080"
depends_on:
infisical-postgres:
condition: service_healthy
valkey:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/api/status"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
# PMS-958: an S3-compatible object store for the `s3` storage backend and
# the `tests/s3_storage.rs` suite. Opt-in behind the `s3` profile
# (`just dev-s3`), because no integration is a hard requirement: the server
# keeps writing to the `attachments` volume until STORAGE_BACKEND=s3 is set
# and it is restarted. Ports publish on loopback only, like postgres and
# mailpit (PMS-496).
#
# PMS-1390: source is `docker.io/bitnamilegacy/minio` (mainline MinIO server,
# DEVELOPMENT build) because MinIO retracted anonymous access to both
# `quay.io/minio/minio` and `docker.io/minio/minio` and this dev image
# became unpullable. Bitnami owns the entrypoint, so no `command:` is
# spelled out here (the entrypoint runs `minio server` with the console on
# 9001), and the data volume mounts at `/bitnami/minio/data` (bitnami's
# non-root UID 1001 owns that path in the image and cannot chown a fresh
# named volume mounted at `/data`). CI extracts the binary from the same
# image and runs it directly in `integration.yml`, bypassing the entrypoint
# so dev and CI take MinIO from one place.
# SPEC-10.143
minio:
profiles: ["s3"]
container_name: dev-mokosh-minio-${USER:?USER missing - run via just dev}
image: docker.io/bitnamilegacy/minio@sha256:451fe6858cb770cc9d0e77ba811ce287420f781c7c1b806a386f6896471a349c
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:?MINIO_ROOT_USER missing - copy the key from .env.example into .env}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:?MINIO_ROOT_PASSWORD missing - copy the key from .env.example into .env and set a value}
volumes:
- minio-data:/bitnami/minio/data
networks:
- private
ports:
# SPEC-10.135
# PMS-900: host side from .env, so a second checkout running
# `just dev-s3` does not collide. The server reaches MinIO in-network
# at `minio:9000`, so these two are host-side tooling only (the console,
# and `tests/s3_storage.rs` when it is pointed at localhost).
- "127.0.0.1:${MOKOSH_MINIO_API_HOST_PORT:-29000}:9000"
- "127.0.0.1:${MOKOSH_MINIO_CONSOLE_HOST_PORT:-29001}:9001"
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 5s
timeout: 5s
retries: 12
# PostgreSQL database for the Mokosh API server (the app's primary
# store, separate from Infisical's). Reachable in-network as
# `postgres:5432` and on the host as `127.0.0.1:${MOKOSH_PG_HOST_PORT}`
# (loopback only, PMS-496) for sqlx-cli.
postgres:
container_name: dev-mokosh-postgres-${USER:?USER missing - run via just dev}
# https://hub.docker.com/_/postgres
image: postgres:18.2-alpine3.23
environment:
POSTGRES_DB: ${MOKOSH_PG_DB:-mokosh}
POSTGRES_USER: ${MOKOSH_PG_USER:-postgres}
# PMS-496: no default. `just ensure-env` generates a per-host secret into
# .env; fail loudly here rather than silently booting with `postgres`.
POSTGRES_PASSWORD: ${MOKOSH_PG_PASSWORD:?MOKOSH_PG_PASSWORD missing - run `just dev` (ensure-env generates a per-host secret)}
# PMS-489: the split request-serving roles (mokosh_migrator / mokosh_app)
# are no longer provisioned by a postgres initdb.d script. The server
# self-provisions them at startup from MOKOSH_ADMIN_DATABASE_URL (the
# POSTGRES_USER superuser), so postgres only needs its own superuser env.
# Postgres 18 changed the default PGDATA from /var/lib/postgresql/
# data to /var/lib/postgresql/<major>/docker. We pin it back into
# the named volume so state survives container recreates regardless
# of the upstream image's default. Using a `pgdata` subdir of the
# mount point sidesteps the postgres-entrypoint quirk that refuses
# to initdb into a non-empty directory.
# SPEC-10.136
PGDATA: /var/lib/postgresql/data/pgdata
networks:
- private
ports:
# SPEC-10.135
# PMS-496: published on LOOPBACK ONLY. host-side sqlx-cli (just
# migrate-run) connects via localhost:${MOKOSH_PG_HOST_PORT}; sibling
# containers reach this DB by in-network DNS `postgres:5432` and need no
# host publish at all. Do NOT reintroduce a LAN-IP bind here: the var
# that carried one was derived from the first non-loopback interface
# (which can be public), so binding the port to it exposed the app DB -
# and the BYPASSRLS mokosh_migrator role reachable through it - to the
# LAN/internet with weak default credentials. If a non-loopback bind is ever genuinely
# required, introduce an explicit private-IP env var with NO default
# (e.g. `${MOKOSH_PG_PRIVATE_BIND_IP:?...}`) and only after a host firewall
# is confirmed to deny 5432/5433 inbound on every non-loopback interface.
- "127.0.0.1:${MOKOSH_PG_HOST_PORT:-5433}:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 10
# Mailpit captures every outgoing email locally. mokosh-server points
# SMTP_HOST=mailpit in the dev env (see the server service below); the
# web UI is at http://localhost:8025. State is intentionally
# ephemeral - no volume mount, restart clears the inbox. MP_DELIVER is
# false, so nothing leaves the box whatever SMTP_FROM says.
mailpit:
container_name: dev-mokosh-mailpit-${USER:?USER missing - run via just dev}
image: axllent/mailpit:v1.27
restart: unless-stopped
environment:
MP_SMTP_AUTH_ACCEPT_ANY: "true"
MP_SMTP_AUTH_ALLOW_INSECURE: "true"
MP_DELIVER: "false"
networks:
- private
ports:
# Loopback-only on both ports, and the HOST side of each comes from
# .env (PMS-900). Two checkouts on one box each publish mailpit, so a
# literal host port makes the second `just dev` fail with "Bind for
# 127.0.0.1:1025 failed: port is already allocated"; the note that used
# to sit here told the reader to edit this file, which a shared
# committed file cannot absorb. Change the two keys in your own .env
# instead. Mailpit's container-side ports stay 1025/8025 either way.
- "127.0.0.1:${MOKOSH_MAILPIT_SMTP_HOST_PORT:-1025}:1025" # SMTP submission (mokosh-server -> mailpit)
- "127.0.0.1:${MOKOSH_MAILPIT_WEB_HOST_PORT:-8025}:8025" # web UI (developer browser)
# Mokosh API server. Built from the dev Dockerfile; source mounted for
# live reload via `cargo run`.
# SPEC-10.137
server:
container_name: dev-mokosh-server-${USER:?USER missing - run via just dev}
build:
context: .
dockerfile: Dockerfile
environment:
HOST: 0.0.0.0
PORT: ${MOKOSH_PORT:?MOKOSH_PORT missing - run `just dev` (which generates .env from .env.example)}
ENVIRONMENT: development
# The server's own public base URL. Traefik is the sole ingress and this
# service publishes no host port, so the only address that reaches it is
# the routed hostname below (same value as OIDC_AUDIENCE).
BASE_URL: https://${USER}-mokosh-api.a8n.run
# Memory cap, not CPU sizing: serialise rustc so the final mokosh_server
# lib compile does not race another peaking process on a memory-constrained
# dev box (earlyoom SIGTERMs the container at ~1.5 GB free), paired with the
# profile.dev tuning in Cargo.toml (debug=0, codegen-units=256). A box with
# headroom can set CARGO_BUILD_JOBS in .env to a higher value or `default`.
# SPEC-10.138
CARGO_BUILD_JOBS: ${CARGO_BUILD_JOBS:-1}
# Reach the in-stack postgres by service-DNS name. PMS-285: the split
# roles activate RLS at runtime. DATABASE_URL connects as the privileged
# `mokosh_migrator` (BYPASSRLS) - it runs migrations + bootstrap + the
# cross-tenant workers; MOKOSH_APP_DATABASE_URL connects as the
# unprivileged `mokosh_app` (NOBYPASSRLS) used for every request-serving
# query, so a forgotten `WHERE tenant_id` filter fail-closes to zero rows.
# PMS-489: the server self-provisions both roles at startup. On first boot
# mokosh_migrator cannot connect, so the server uses MOKOSH_ADMIN_DATABASE_URL
# (the postgres superuser) to CREATE the roles with MOKOSH_MIGRATOR_PASSWORD /
# MOKOSH_APP_PASSWORD, then closes that pool. Subsequent boots skip it.
# PMS-496: DB passwords carry no defaults. `just ensure-env` generates
# per-host secrets into .env; an unset value fails the stack loudly rather
# than silently provisioning the roles with `mokosh_*_dev` / `postgres`.
DATABASE_URL: postgres://mokosh_migrator:${MOKOSH_MIGRATOR_PASSWORD:?MOKOSH_MIGRATOR_PASSWORD missing - run `just dev` (ensure-env generates a per-host secret)}@postgres:5432/${MOKOSH_PG_DB:-mokosh}
MOKOSH_APP_DATABASE_URL: postgres://mokosh_app:${MOKOSH_APP_PASSWORD:?MOKOSH_APP_PASSWORD missing - run `just dev` (ensure-env generates a per-host secret)}@postgres:5432/${MOKOSH_PG_DB:-mokosh}
MOKOSH_ADMIN_DATABASE_URL: postgres://${MOKOSH_PG_USER:-postgres}:${MOKOSH_PG_PASSWORD:?MOKOSH_PG_PASSWORD missing - run `just dev` (ensure-env generates a per-host secret)}@postgres:5432/${MOKOSH_PG_DB:-mokosh}
MOKOSH_MIGRATOR_PASSWORD: ${MOKOSH_MIGRATOR_PASSWORD:?MOKOSH_MIGRATOR_PASSWORD missing - run `just dev` (ensure-env generates a per-host secret)}
MOKOSH_APP_PASSWORD: ${MOKOSH_APP_PASSWORD:?MOKOSH_APP_PASSWORD missing - run `just dev` (ensure-env generates a per-host secret)}
# Outbound email. Dev defaults point at the mailpit service
# alongside this one; messages land in http://localhost:8025.
# Production deploys override these via secrets; setting
# SMTP_HOST empty drops back to LogMailer (links go to docker
# logs). The .env.example block above these keys is the reference.
#
# PMS-1013: MAIL_PROVIDER=smtp is inferred here from SMTP_HOST
# (mailpit); leave the variable empty so the .env.example default
# applies. Set MAIL_PROVIDER=log explicitly to force the LogMailer
# while the dev mailpit is reachable.
MAIL_PROVIDER: ${MAIL_PROVIDER:-}
SMTP_HOST: ${SMTP_HOST:-mailpit}
SMTP_PORT: ${SMTP_PORT:-1025}
SMTP_USERNAME: ${SMTP_USERNAME:-}
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
# Display name MUST NOT contain unquoted parens; they're RFC 5322
# comment syntax. If you want "Mokosh (dev)" wrap it in quotes
# at the env-var level.
SMTP_FROM: ${SMTP_FROM:-Mokosh Dev <noreply@mokosh.localdev>}
SMTP_TLS: ${SMTP_TLS:-none}
# PMS-1482: Bunyip mailer relay; empty by default, so dev stays on
# the mailpit SMTP path above unless an operator opts in.
BUNYIP_MAILER_URL: ${BUNYIP_MAILER_URL:-}
BUNYIP_MAILER_CLIENT_ID: ${BUNYIP_MAILER_CLIENT_ID:-}
BUNYIP_MAILER_CLIENT_SECRET: ${BUNYIP_MAILER_CLIENT_SECRET:-}
# Infisical is an opt-in profile, so this stays EMPTY on a plain
# `just dev` and the readiness probe reports "skipped" instead of
# 503ing against an absent host (PMS-707). `just dev-infisical`
# writes the service-DNS URL into .env under the MOKOSH_SERVER_
# name; the plain INFISICAL_URL in .env is the host-side localhost
# URL that `just infisical-bootstrap` consumes, so the two contexts
# need two names.
INFISICAL_ADDRESS: ${MOKOSH_SERVER_INFISICAL_ADDRESS:-}
INFISICAL_ENVIRONMENT: ${INFISICAL_ENVIRONMENT:-dev}
# PMS-967: `database` (the default) or `infisical`. The `:-` default
# reproduces the code's own fallback in SecretsConfig::from_env, so an
# unset variable behaves the same here as it does in production.
SECRET_BACKEND: ${SECRET_BACKEND:-database}
# PMS-1424: the APPLICATION tier's own selector. Separate from the line
# above, which selects the tenant tier: that one accepts only `database`
# and `infisical`, because a tenant secret is a per-tenant write, so
# pointing it at `file` stopped the boot while appearing to be the
# documented way to move SMTP_PASSWORD.
APP_SECRET_BACKEND: ${APP_SECRET_BACKEND:-database}
# PMS-988: directory the application-tier file secret provider reads.
# Empty means the file provider is not built; the `:-` default reproduces
# the code's own behaviour when APP_SECRETS_DIR is unset.
APP_SECRETS_DIR: ${APP_SECRETS_DIR:-}
# PMS-1537: bunyip's host-secrets route and the machine credential that
# reads it. Empty in dev, which is what every self-hosted deployment
# reads: no URL means the bunyip provider is not built, and the Google
# client pair comes from whatever APP_SECRET_BACKEND names. A dev box
# pointing at a real bunyip sets all three.
BUNYIP_SECRETS_URL: ${BUNYIP_SECRETS_URL:-}
BUNYIP_SECRETS_CLIENT_ID: ${BUNYIP_SECRETS_CLIENT_ID:-}
BUNYIP_SECRETS_CLIENT_SECRET: ${BUNYIP_SECRETS_CLIENT_SECRET:-}
# PMS-982: `environment`, the only kind reachable via the SINGLE-provider
# slot today. The `:-` default reproduces the code's own fallback in
# ConfigSelection::from_env.
CONFIG_BACKEND: ${CONFIG_BACKEND:-environment}
# PMS-987: comma-separated priority list of enabled configuration
# providers (e.g. `file,database,environment`). Empty means the
# hosting profile's default. The chain is DORMANT in PMS-987 - it
# builds but no read path resolves through it yet.
CONFIG_PROVIDERS: ${CONFIG_PROVIDERS:-}
# PMS-987: directory the file configuration provider reads (unset =
# not enabled, silent).
CONFIG_FILE_DIR: ${CONFIG_FILE_DIR:-}
# PMS-987: Bunyip API base and machine credential for the Bunyip
# configuration provider. Unset URL means the provider builds empty
# and issues no request.
BUNYIP_CONFIG_URL: ${BUNYIP_CONFIG_URL:-}
BUNYIP_CONFIG_CLIENT_ID: ${BUNYIP_CONFIG_CLIENT_ID:-}
BUNYIP_CONFIG_CLIENT_SECRET: ${BUNYIP_CONFIG_CLIENT_SECRET:-}
# PMS-981: authentication provider enablement, comma-separated in
# priority order (`bunyip,local` on saas, `local` on self-hosted). The
# `:-` blank default reproduces the code's own fallback in
# AuthProviderSelection::from_env, which resolves an unset value to
# the hosting profile's default; the seam is DORMANT so this variable
# changes nothing today but is declared here (PMS-836) so a future
# wiring PR does not need a compose.dev.yml change.
AUTH_PROVIDERS: ${AUTH_PROVIDERS:-}
INFISICAL_PROJECT_ID: ${INFISICAL_PROJECT_ID:-}
INFISICAL_CLIENT_ID: ${INFISICAL_CLIENT_ID:-}
INFISICAL_CLIENT_SECRET: ${INFISICAL_CLIENT_SECRET:-}
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET missing - run `just dev` (which generates .env from .env.example)}
ENCRYPTION_KEY: ${ENCRYPTION_KEY:?ENCRYPTION_KEY missing - run `just dev` (which generates .env from .env.example)}
# bunyip-as-OP Resource-Server verifier (the sole OP after PMS-295,
# which removed mokosh-auth / mechanism 2). OIDC_ISSUER must equal the
# token `iss` AND bunyip's advertised discovery issuer; OIDC_AUDIENCE
# must equal the `audience` on the mokosh-apps oauth_clients row in
# bunyip-api. The RS path fetches bunyip's keys over JWKS, so mokosh
# holds no local signing key and exposes no /oauth2/* endpoints.
OIDC_ISSUER: https://${USER}-bunyip-api.a8n.run
OIDC_AUDIENCE: https://${USER}-mokosh-api.a8n.run
# PMS-998: the client id bunyip addresses a back-channel logout token
# to, which is the `client_id` of that same oauth_clients row rather
# than its `audience`. Empty in dev, because bunyip only notifies a
# client whose `backchannel_logout_uri` is set (BUNYIP-636) and the dev
# client row has none; empty means the receiver refuses everything,
# which is the right posture for a deployment nothing is notifying.
OIDC_BACKCHANNEL_CLIENT_ID: ${OIDC_BACKCHANNEL_CLIENT_ID:-}
# PMS-1193 / BUNYIP-641: Bunyip's suite-wide provider-status aggregator
# (BUNYIP-634) calls GET /api/v1/admin/providers/status with HTTP Basic
# against these two values. Both empty in dev = the machine-credential
# path is disabled and the endpoint gates on `RequireAdmin` alone,
# which is the pre-PMS-1193 behaviour a self-hosted deployment without
# Bunyip aggregation runs on. Staging and prod get real values through
# the SOPS compose-secrets. Reference: bunyip/docs/provider-status-contract.md.
BUNYIP_STATUS_CLIENT_ID: ${BUNYIP_STATUS_CLIENT_ID:-}
BUNYIP_STATUS_CLIENT_SECRET: ${BUNYIP_STATUS_CLIENT_SECRET:-}
# PMS-1208: Bunyip user-directory client (SaaS mode only). All three
# unset in dev by default = standalone mode, no lookup runs. Set
# all three together to enable the pre-invitation existence check
# against Bunyip's `/v1/users/lookup`. Partial config warns and
# disables the gate. Reference:
# mokosh-server/src/modules/auth/bunyip_directory.rs.
BUNYIP_API_BASE_URL: ${BUNYIP_API_BASE_URL:-}
BUNYIP_DIRECTORY_CLIENT_ID: ${BUNYIP_DIRECTORY_CLIENT_ID:-}
BUNYIP_DIRECTORY_CLIENT_SECRET: ${BUNYIP_DIRECTORY_CLIENT_SECRET:-}
# PMS-1212 (PSA-70): Google Contacts OAuth client. Unset locally, so the
# integration reports itself unconfigured rather than half-working.
# Browser-visible origin of the client that talks to this API. Must
# equal it byte-for-byte: it is the CORS_ORIGIN default and the base
# for emailed reset/invite links. PMS-837 removed the Google OAuth
# client id/secret/redirect keys and the super-admin email allowlist
# along with the Google sign-in routes.
CLIENT_ORIGIN: ${CLIENT_ORIGIN:-http://localhost:4301}
# First-run admin bootstrap (DEV ONLY). Ignored once any user exists.
ADMIN_EMAIL: ${ADMIN_EMAIL:-}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-}
# MAPPS-649: the per-MSP `PORTAL_HOST_SUFFIX` env retired with the
# collapse onto a single portal subdomain. The portal now lives at
# one host (typically `portal.<apex>`) and the visitor addresses
# their Company from the URL path (`/portal/{portal_id}/*`). If
# you are upgrading an older deploy, drop `PORTAL_HOST_SUFFIX`
# from your own `.env` and remove any Traefik / DNS wildcard that
# pointed at `*.client.<apex>`. See
# docs/dev-docs/portal-single-host-cutover.md.
# PMS-836: this map enumerates the container's environment, so a variable
# the code reads but that has no line here CANNOT be set from .env - the
# operator edits .env, sees no error, and the feature stays off. Every
# remaining variable the server process reads is therefore listed below,
# each defaulting to the fallback the code already applies when unset, so
# an untouched .env behaves exactly as before. scripts/check-env-example.nu
# fails `just check` if a new read is added without a line here.
RUN_MIGRATIONS: ${RUN_MIGRATIONS:-true}
# PMS-729 / MAPPS-649: CORS allow-list, comma-separated. Empty
# passes through as `[CLIENT_ORIGIN]` on the server side. Add the
# portal origin here when the SPA is served on a separate portal
# host in dev (e.g. `http://portal.localhost:4301`) so a browser
# tab on that origin can POST credentialed calls. See
# `.env.example` for a full example and `src/api/cors_origin.rs`
# for the predicate.
CORS_ORIGIN: ${CORS_ORIGIN:-}
# MAPPS-920: Domain= attribute for the contact-portal refresh cookie,
# set when the SPA runs on a different subdomain of the API's apex.
PORTAL_COOKIE_DOMAIN: ${PORTAL_COOKIE_DOMAIN:-}
# MAPPS-425 / PMS-748 / MAPPS-429: the emailed-link and email-branding
# trio. SPA_BASE_URL falls back to CLIENT_ORIGIN, so it only needs setting
# on a stack where the SPA is not the login origin; PUBLIC_API_BASE_URL is
# what makes the tenant logo in a request-form email an absolute src, and
# unset means the mail carries no logo at all.
SPA_BASE_URL: ${SPA_BASE_URL:-}
ABUSE_CONTACT_EMAIL: ${ABUSE_CONTACT_EMAIL:-}
PUBLIC_API_BASE_URL: ${PUBLIC_API_BASE_URL:-}
# PMS-591: shared secret for the BUNYIP-211 `account_deleted` webhook.
# Empty falls back to the built-in dev value, which only development /
# dev / test accept (resolve_secret, PMS-499).
BUNYIP_WEBHOOK_SECRET: ${BUNYIP_WEBHOOK_SECRET:-}
# PMS-587 / PMS-809: empty means "use the built-in default" for the
# trusted-proxy ranges, and "exempt nothing" for the outbound SSRF guard.
TRUSTED_PROXY_CIDR: ${TRUSTED_PROXY_CIDR:-}
OUTBOUND_PRIVATE_ALLOWLIST: ${OUTBOUND_PRIVATE_ALLOWLIST:-}
# PMS-657 / BUNYIP-475 / PMS-658 / PMS-983: login-location enrichment and
# the notify-and-approve gate. All three are off when empty; the gate is
# now read through `config::flags::LOGIN_APPROVAL_ENABLED`, which parses
# the same values.
IP2LOCATION_DB_PATH: ${IP2LOCATION_DB_PATH:-}
IP2PROXY_DB_PATH: ${IP2PROXY_DB_PATH:-}
LOGIN_APPROVAL_ENABLED: ${LOGIN_APPROVAL_ENABLED:-}
# Let a verified bunyip identity JIT-provision a personal tenant on
# first sight. Off by default; staging opts in. Parses the same way
# as LOGIN_APPROVAL_ENABLED.
ALLOW_UNINVITED_BUNYIP_SIGNUP: ${ALLOW_UNINVITED_BUNYIP_SIGNUP:-}
# PMS-904: self-hosted (default) or saas. Empty means unset, which the
# code resolves to self-hosted, so the dev stack sends every email.
MOKOSH_DEPLOYMENT_MODE: ${MOKOSH_DEPLOYMENT_MODE:-}
# PMS-1317: the storage root every stored object hangs off. Defaulted to
# the `attachments` named volume below rather than the code's
# CWD-relative `./attachments`, so an upload survives `just dev`
# rebuilding the image.
#
# ATTACHMENT_DIR is forwarded beside it as the deprecated alias, with an
# EMPTY default on purpose: the resolver takes the first non-blank of the
# two, so a default here would shadow STORAGE_ROOT and every dev stack
# would silently keep running on the deprecated name.
# SPEC-10.140
STORAGE_ROOT: ${STORAGE_ROOT:-/data/attachments}
ATTACHMENT_DIR: ${ATTACHMENT_DIR:-}
ATTACHMENT_MAX_BYTES: ${ATTACHMENT_MAX_BYTES:-}
# PMS-923: KB article images. Default reproduces the code's own 5 MiB.
KB_ATTACHMENT_MAX_BYTES: ${KB_ATTACHMENT_MAX_BYTES:-}
TENANT_LOGO_MAX_BYTES: ${TENANT_LOGO_MAX_BYTES:-}
# MAPPS-618/622: the other five branding caps, declared in
# src/config/registry.rs by PMS-982. Like their siblings above the `:-`
# default is empty, which IS the code's own fallback: max_bytes discards
# an unparseable or non-positive value and takes
# BrandAssetKind::default_max_bytes (1 MiB logo, 512 KiB favicon, 2 MiB
# background). Repeating those numbers here would be a second home for
# them, and .env.example carries them as the operator-facing default.
BRANDING_TENANT_FAVICON_MAX_BYTES: ${BRANDING_TENANT_FAVICON_MAX_BYTES:-}
BRANDING_TENANT_BACKGROUND_MAX_BYTES: ${BRANDING_TENANT_BACKGROUND_MAX_BYTES:-}
BRANDING_COMPANY_LOGO_MAX_BYTES: ${BRANDING_COMPANY_LOGO_MAX_BYTES:-}
BRANDING_COMPANY_FAVICON_MAX_BYTES: ${BRANDING_COMPANY_FAVICON_MAX_BYTES:-}
BRANDING_COMPANY_BACKGROUND_MAX_BYTES: ${BRANDING_COMPANY_BACKGROUND_MAX_BYTES:-}
# PMS-958, renamed by PMS-1317: which provider stores objects, and the
# S3-compatible store it uses. Empty resolves to local, so the dev stack
# keeps writing to the `attachments` volume unless an operator opts in
# to the `s3` profile's MinIO (`just dev-s3`) and sets these.
STORAGE_PROVIDER: ${STORAGE_PROVIDER:-}
STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT:-}
STORAGE_S3_BUCKET: ${STORAGE_S3_BUCKET:-}
STORAGE_S3_REGION: ${STORAGE_S3_REGION:-}
STORAGE_S3_ACCESS_KEY_ID: ${STORAGE_S3_ACCESS_KEY_ID:-}
STORAGE_S3_SECRET_ACCESS_KEY: ${STORAGE_S3_SECRET_ACCESS_KEY:-}
STORAGE_S3_PATH_STYLE: ${STORAGE_S3_PATH_STYLE:-}
# The deprecated aliases, forwarded so an existing `.env` keeps working
# for the one release they live. Each is honoured only when its
# STORAGE_ name above is unset, and using one logs a deprecation line.
STORAGE_BACKEND: ${STORAGE_BACKEND:-}
S3_ENDPOINT: ${S3_ENDPOINT:-}
S3_BUCKET: ${S3_BUCKET:-}
S3_REGION: ${S3_REGION:-}
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-}
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-}
S3_PATH_STYLE: ${S3_PATH_STYLE:-}
# RS verifier knobs beyond the issuer/audience pair above; empty keeps the
# built-in 600s JWKS cache and 30s clock leeway. OIDC_DEFAULT_TENANT_ID is
# the shared landing tenant bunyip users JIT into (PMS-239).
OIDC_JWKS_CACHE_TTL_SECS: ${OIDC_JWKS_CACHE_TTL_SECS:-}
OIDC_LEEWAY_SECONDS: ${OIDC_LEEWAY_SECONDS:-}
OIDC_DEFAULT_TENANT_ID: ${OIDC_DEFAULT_TENANT_ID:-}
# Contact-portal login and magic-link redeem per-IP budget; empty keeps
# the built-in 10 attempts per 60s.
CONTACT_LOGIN_IP_RATE_MAX: ${CONTACT_LOGIN_IP_RATE_MAX:-}
CONTACT_LOGIN_IP_RATE_WINDOW_SECS: ${CONTACT_LOGIN_IP_RATE_WINDOW_SECS:-}
# Stripe REST base, overridable so a test can point checkout at a stub;
# empty uses https://api.stripe.com.
STRIPE_API_BASE: ${STRIPE_API_BASE:-}
# PayPal REST base, same purpose (PMS-969); empty uses PayPal's own hosts.
PAYPAL_API_BASE: ${PAYPAL_API_BASE:-}
# PMS-710 demo-data gate, the template tenant its rows are copied from,
# and the upstream version probe. All three are off/default when empty.
MOKOSH_DEMO_SEED: ${MOKOSH_DEMO_SEED:-}
MOKOSH_SEED_TENANT_ID: ${MOKOSH_SEED_TENANT_ID:-}
MOKOSH_UPDATE_CHECK_URL: ${MOKOSH_UPDATE_CHECK_URL:-}
# MAPPS-457: hard ceiling on POST /api/v1/tenants. Empty leaves creation
# uncapped (the code default); a positive integer 409s once the total
# tenant count reaches it. Kept forwardable in dev so a stress-test can
# set the cap without a container rebuild.
MOKOSH_MAX_TENANTS: ${MOKOSH_MAX_TENANTS:-}
RUST_LOG: ${RUST_LOG:-info,mokosh_server=debug}
networks:
- private
- traefik-public
# Traefik is the sole ingress for the dev stack; the server publishes no
# LAN-IP host port. Routing and Let's Encrypt TLS termination come from the
# shared Traefik via the labels below. (postgres still publishes its host
# port for sqlx-cli; see that service.)
#
# List (sequence) syntax is REQUIRED here, not the usual map syntax.
# Docker Compose interpolates ${USER} inside string VALUES but NOT
# inside map KEYS (verified on Compose v2.40). The router name lives
# in the label key, so map syntax leaves a literal `${USER}` in the
# router name, Traefik rejects it, and the host never routes (default
# cert + 404). In list form the whole "key=value" is one string value,
# so ${USER} in the router name interpolates correctly.
# SPEC-10.142
labels:
- traefik.enable=true
- traefik.docker.network=network-traefik-public
- traefik.http.routers.mokosh-api-${USER}.rule=Host(`${USER}-mokosh-api.a8n.run`)
- traefik.http.routers.mokosh-api-${USER}.entrypoints=nebula-secure
- traefik.http.routers.mokosh-api-${USER}.tls.certresolver=cert-cloudflare
- traefik.http.services.mokosh-api-${USER}.loadbalancer.server.port=${MOKOSH_PORT}
# The bunyip-as-OP RS verifier (oidc_rs.rs) fetches
# `${OIDC_ISSUER}/.well-known/openid-configuration`, but inside the
# container the issuer host resolves to the box's PUBLIC edge (self-signed
# cert + 404 on the OP path). Pin it to the LOCAL Traefik on the shared
# network, which serves the OP with a valid Let's Encrypt cert. Override
# BUNYIP_OP_TRAEFIK_IP in .env on a box whose Traefik publishes
# nebula-secure on a different IP.
# SPEC-10.141
extra_hosts:
- "${USER}-bunyip-api.a8n.run:${BUNYIP_OP_TRAEFIK_IP:-172.30.0.11}"
# SPEC-10.139
volumes:
- ./src:/app/src
- ./crates:/app/crates
- ./Cargo.toml:/app/Cargo.toml
- ./Cargo.lock:/app/Cargo.lock
# build.rs captures git hash / describe / build date as
# compile-time env vars consumed by src/version.rs. Without
# this mount cargo sees `build = "build.rs"` in Cargo.toml,
# cannot find the file, and fails the workspace compile.
- ./build.rs:/app/build.rs
- ./migrations:/app/migrations
# PMS-640: mount the integration tests so `just pre-push`'s
# `cargo {check,clippy} --all-targets` inside this container compiles the
# tests/*.rs binaries. Without this the container never sees tests/, so a
# harness-breaking signature change (e.g. create_api_router) passed the
# local hook and only failed in CI. `tests/` is compile-only here (the
# Postgres-backed run stays in `just test-integration`).
- ./tests:/app/tests
# PMS-1430: the e2e suite, read only, because a `cargo test --lib` guard
# reads it. `pms1427_e2e_page_size` scans `e2e/**.ts` for a `per_page`
# literal above what the API serves and fails loudly when the directory is
# absent, on purpose: a guard that skips when it cannot see its subject
# proves nothing. CI checks the whole repository out and passed; the
# container mounts the tree file by file, so `just pre-push` failed on a
# missing directory rather than on anything a developer had changed.
- ./e2e:/app/e2e:ro
# PMS-1183: the nextest profile `just test-integration` names
# (`--profile ci`, from `.config/nextest.toml`, PMS-1177). This mount
# list enumerates the source tree file by file, so a new top-level
# config directory is invisible in dev until it is added here, and the
# recipe failed with an unknown-profile error while CI, which checks the
# whole repository out, stayed green.
- ./.config:/app/.config
- server-target:/app/target
# PMS-836: uploads (ticket attachments and tenant logos) land under
# STORAGE_ROOT. Without this they live in the container filesystem and
# a rebuild loses them, so a dev tenant's logo disappears on the next
# `just dev`. Mount point must match the STORAGE_ROOT default above.
- attachments:/data/attachments
depends_on:
postgres:
condition: service_healthy
# NB: no dependency on infisical. The mokosh-server binary reads
# INFISICAL_ADDRESS (the readiness probe in src/api/router.rs pings
# it, and reports "skipped" when the address is blank), but it does
# not require Infisical to be up to boot, and Infisical is opt-in
# behind the `infisical` compose profile. A hard depends_on a
# profiled-out service makes compose reject the whole project
# ("depends on undefined service infisical") for every
# `just dev` / `just down`.
mailpit:
# No healthcheck on mailpit; it accepts SMTP from cold start.
# Wait for the container to be running, not healthy.
condition: service_started
volumes:
infisical-postgres-data:
name: dev-mokosh-infisical-postgres-data-${USER:?USER missing - run via just dev}
postgres-data:
name: dev-mokosh-postgres-data-${USER:?USER missing - run via just dev}
server-target:
name: dev-mokosh-server-target-${USER:?USER missing - run via just dev}
attachments:
name: dev-mokosh-attachments-${USER:?USER missing - run via just dev}
minio-data:
name: dev-mokosh-minio-data-${USER:?USER missing - run via just dev}
networks:
private:
name: dev-mokosh-private-${USER:?USER missing - run via just dev}
# Shared Traefik ingress network. Genuinely external (owned by the Traefik
# stack), so compose attaches rather than creates it; it must already exist.
traefik-public:
name: network-traefik-public
external: true