Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
262 lines (255 loc) · 11.2 KB
/
Copy pathdocker-compose.yml
File metadata and controls
262 lines (255 loc) · 11.2 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
# openflipbook — one-command local stack.
#
# cp .env.example .env # drop in FAL_KEY (+ OPENROUTER_API_KEY)
# docker compose up --build # → http://localhost:3000/play
#
# Stores run fully local: Mongo for metadata, Minio (S3-compatible) for image
# blobs — so no Cloudflare R2 / hosted Mongo to provision. The AI still calls
# out (OpenRouter for the planner/VLM, fal for images). For a no-cloud LLM too,
# add the Ollama override: make demo-local (see docker-compose.local.yml).
#
# Overridable defaults are read from `.env` (compose auto-loads it); the values
# below are the local-stack fallbacks, so a bare `docker compose up` just works.
services:
mongo:
image: mongo:7
container_name: openflipbook-mongo
restart: unless-stopped
# Single-node replica set (Wave 8): change streams power the shared-
# session read-along, and Mongo only serves them from a replica set.
# Existing standalone data volumes convert in place — mongo-init runs a
# one-time rs.initiate() pinned to the compose hostname. Clients OUTSIDE
# the compose network (local `pnpm dev` against localhost:27017) need
# `?directConnection=true` on their MONGODB_URI, since the set advertises
# `mongo:27017`.
command: ["--replSet", "rs0", "--bind_ip_all", "--quiet"]
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
mongo-init:
image: mongo:7
container_name: openflipbook-mongo-init
restart: "no"
depends_on:
mongo:
condition: service_healthy
# Idempotent: initiates the set on first boot, no-ops once initiated.
command: >
mongosh --host mongo --quiet --eval
"try { rs.status() } catch (e) { rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'mongo:27017'}]}) }"
# S3-compatible blob store — the local stand-in for Cloudflare R2. The web
# app writes here (R2_ENDPOINT=http://minio:9000). The browser reads images
# through the web app's authorized /api/blobs route.
minio:
# The service keeps its old name so R2_ENDPOINT=http://minio:9000 and
# everything wired to it stay the same, but it is RustFS now: MinIO
# withdrew its public images (quay.io answers 401, Docker Hub has none),
# which broke `docker compose up` and the e2e CI job (2026-09-24).
# RustFS is an Apache-2.0, S3-compatible store; its data format differs
# from MinIO's, so it uses a fresh volume.
image: rustfs/rustfs:1.0.0
container_name: openflipbook-minio
restart: unless-stopped
environment:
RUSTFS_ACCESS_KEY: ${MINIO_ROOT_USER:-openflipbook}
RUSTFS_SECRET_KEY: ${MINIO_ROOT_PASSWORD:-openflipbook-local}
ports:
- "9000:9000" # S3 API; bucket is private
volumes:
- s3-data:/data
# One-shot: create a private bucket. Browsers read authorized same-origin
# /api/blobs URLs; publications expose only their selected immutable files.
# Retries until the store
# answers, then exits -- `web` waits on it completing.
minio-setup:
image: amazon/aws-cli:2.37.1
container_name: openflipbook-minio-setup
depends_on:
- minio
environment:
AWS_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-openflipbook}
AWS_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-openflipbook-local}
AWS_DEFAULT_REGION: us-east-1
R2_BUCKET: ${R2_BUCKET:-openflipbook}
entrypoint: |
/bin/sh -c '
set -e;
s3="aws --endpoint-url http://minio:9000 s3api";
until $$s3 list-buckets >/dev/null 2>&1; do
echo "waiting for the s3 store..."; sleep 1;
done;
$$s3 head-bucket --bucket "$${R2_BUCKET}" 2>/dev/null || $$s3 create-bucket --bucket "$${R2_BUCKET}";
$$s3 delete-bucket-policy --bucket "$${R2_BUCKET}";
echo "s3 bucket $${R2_BUCKET} ready";
'
restart: "no"
backend:
build:
context: .
dockerfile: apps/modal-backend/Dockerfile
container_name: openflipbook-backend
restart: unless-stopped
# Keys come from the root .env (single-file demo) or, for power users, the
# backend's own .env which overrides it. Both optional; neither clobbers
# unset keys.
env_file:
- path: .env
required: false
- path: apps/modal-backend/.env
required: false
environment:
# Weighted multi-reference image conditioning (default on). Set to false
# to A/B against the old text-only generation:
# IMAGE_CONDITIONING=false docker compose up -d backend
IMAGE_CONDITIONING: ${IMAGE_CONDITIONING:-true}
# Zero-key demo mode: deterministic mock providers (no fal/OpenRouter
# calls, no keys needed). MOCK_PROVIDERS=1 docker compose up -d
MOCK_PROVIDERS: ${MOCK_PROVIDERS:-}
# Typed decisions: unset = off. Shadow logs beside the rules and
# changes nothing; see .env.example.
DECISION_MODE: ${DECISION_MODE:-}
DECISION_LIVE: ${DECISION_LIVE:-}
DECISION_TIMEOUT_MS: ${DECISION_TIMEOUT_MS:-}
DECISIONS_CANARY: ${DECISIONS_CANARY:-}
# World Mode: a tap ENTERS the tapped place (an immersive scene / a closer
# sub-map) instead of explaining a topic, and places persist + reopen.
# GRADUATED to default ON (2026-08-21). One knob kills the whole set:
# WORLD_MODE=false docker compose up -d
# The geometry + scale-ladder flags follow it unless individually set.
WORLD_MODE: ${WORLD_MODE:-true}
WORLD_IDENTITY_STRICT: ${WORLD_IDENTITY_STRICT:-false}
GEOMETRIC_WORLD: ${GEOMETRIC_WORLD:-${WORLD_MODE:-true}}
SCALE_LADDER_NAV: ${SCALE_LADDER_NAV:-${WORLD_MODE:-true}}
SCALE_OUTWARD: ${SCALE_OUTWARD:-${WORLD_MODE:-true}}
SCALE_AROUND_LOGICAL: ${SCALE_AROUND_LOGICAL:-${WORLD_MODE:-true}}
# Map-pan: "expand" (Around) outpaints the world outward in 4 directions
# instead of blooming neighbour subjects. Default off:
# EXPAND_MAP_PAN=true docker compose up -d backend
EXPAND_MAP_PAN: ${EXPAND_MAP_PAN:-false}
# Force public resolvers — Docker's default 127.0.0.11 link-local resolver
# has been flaking on the fal.ai / r2.cloudflarestorage.com hosts during
# E2E runs (sporadic ESERVFAIL / EAI_AGAIN), which manifests as
# ConnectError mid-stream and tanks the click-to-next + style-pin tests.
dns:
- 1.1.1.1
- 8.8.8.8
ports:
- "8787:8787"
healthcheck:
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:8787/health"]
interval: 15s
timeout: 5s
retries: 3
place-worker:
profiles: ["world-build"]
build:
context: .
dockerfile: apps/web/Dockerfile
target: place-worker
restart: unless-stopped
# Allow in-flight provider, download and storage operations to drain.
stop_grace_period: 360s
env_file:
- path: .env
required: false
- path: apps/web/.env.local
required: false
environment:
MODAL_API_URL: http://backend:8787
MONGODB_URI: ${MONGODB_URI:-mongodb://mongo:27017/?directConnection=true}
MONGODB_DB: ${MONGODB_DB:-openflipbook}
R2_ENDPOINT: ${R2_ENDPOINT:-http://minio:9000}
R2_BUCKET: ${R2_BUCKET:-openflipbook}
R2_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-openflipbook}
R2_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-openflipbook-local}
R2_PUBLIC_BASE_URL: ${R2_PUBLIC_BASE_URL:-/api/blobs}
depends_on:
backend:
condition: service_healthy
mongo-init:
condition: service_completed_successfully
minio-setup:
condition: service_completed_successfully
web:
build:
context: .
dockerfile: apps/web/Dockerfile
# NEXT_PUBLIC_* are inlined at BUILD time, so runtime env_file can't
# carry them — they must arrive as build args or the image ships the
# flag-off bundle (the "why did consistency regress" footgun: world
# mode seeded OFF in every fresh docker session). Both follow the root
# .env's WORLD_MODE (graduated default ON) so the single-file demo
# stays single-file and WORLD_MODE=false restores the classic bundle.
args:
NEXT_PUBLIC_WORLD_MODE: ${NEXT_PUBLIC_WORLD_MODE:-${WORLD_MODE:-true}}
NEXT_PUBLIC_WORLD_IDENTITY_STRICT: ${NEXT_PUBLIC_WORLD_IDENTITY_STRICT:-false}
NEXT_PUBLIC_DOM_LABELS: ${NEXT_PUBLIC_DOM_LABELS:-${WORLD_MODE:-true}}
NEXT_PUBLIC_ON_RAMP_COACH: ${NEXT_PUBLIC_ON_RAMP_COACH:-false}
NEXT_PUBLIC_ENTER_COACH: ${NEXT_PUBLIC_ENTER_COACH:-false}
# DESCENT_AUTO: background arrival clips (~$0.24/edge). Default off.
NEXT_PUBLIC_DESCENT_AUTO: ${NEXT_PUBLIC_DESCENT_AUTO:-}
NEXT_PUBLIC_SPATIAL_TRANSITIONS: ${NEXT_PUBLIC_SPATIAL_TRANSITIONS:-}
NEXT_PUBLIC_WORLD_LAYOUT_CONTROL: ${NEXT_PUBLIC_WORLD_LAYOUT_CONTROL:-}
NEXT_PUBLIC_WORLD_ROUTE_DRAW: ${NEXT_PUBLIC_WORLD_ROUTE_DRAW:-}
NEXT_PUBLIC_IMAGE_LED_COPY_FIRST: ${NEXT_PUBLIC_IMAGE_LED_COPY_FIRST:-}
NEXT_PUBLIC_WORLD_SCENES: ${NEXT_PUBLIC_WORLD_SCENES:-0}
NEXT_PUBLIC_SKETCH_ENABLED: ${NEXT_PUBLIC_SKETCH_ENABLED:-0}
container_name: openflipbook-web
restart: unless-stopped
# Same posture as the backend: the root .env (single-file demo) carries
# the world/geo feature flags — the web's server routes gate geometry
# seeding (GEOMETRIC_WORLD) and scale-nav on them, so without this the
# docker stack silently ran with seeding off while local dev had it on.
# apps/web/.env.local overrides; the compose-network values below win last.
env_file:
- path: .env
required: false
- path: apps/web/.env.local
required: false
dns:
- 1.1.1.1
- 8.8.8.8
environment:
NODE_ENV: production
HOSTNAME: 0.0.0.0
PORT: "3000"
# Backend URL is fixed inside the compose network.
MODAL_API_URL: http://backend:8787
# Metadata → local Mongo by default.
MONGODB_URI: ${MONGODB_URI:-mongodb://mongo:27017/?directConnection=true}
MONGODB_DB: ${MONGODB_DB:-openflipbook}
# Blobs → local Minio by default. R2_ENDPOINT makes the S3 client target
# Minio (path-style); the browser uses the authorized same-origin route.
R2_ENDPOINT: ${R2_ENDPOINT:-http://minio:9000}
R2_BUCKET: ${R2_BUCKET:-openflipbook}
R2_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-openflipbook}
R2_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-openflipbook-local}
R2_PUBLIC_BASE_URL: ${R2_PUBLIC_BASE_URL:-/api/blobs}
# The web server routes gate geometry seeding + scale-nav on these —
# same graduated single-knob coupling as the backend block above.
WORLD_MODE: ${WORLD_MODE:-true}
WORLD_IDENTITY_STRICT: ${WORLD_IDENTITY_STRICT:-false}
GEOMETRIC_WORLD: ${GEOMETRIC_WORLD:-${WORLD_MODE:-true}}
SCALE_LADDER_NAV: ${SCALE_LADDER_NAV:-${WORLD_MODE:-true}}
SCALE_OUTWARD: ${SCALE_OUTWARD:-${WORLD_MODE:-true}}
SCALE_AROUND_LOGICAL: ${SCALE_AROUND_LOGICAL:-${WORLD_MODE:-true}}
ports:
- "3000:3000"
depends_on:
backend:
condition: service_healthy
mongo:
condition: service_healthy
mongo-init:
condition: service_completed_successfully
minio-setup:
condition: service_completed_successfully
volumes:
mongo-data:
s3-data: