Repository navigation
Expand file tree
/
Copy pathcompose.dev.yml
More file actions
214 lines (202 loc) · 10.9 KB
/
Copy pathcompose.dev.yml
File metadata and controls
214 lines (202 loc) · 10.9 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
# =============================================================================
# LOCAL DEVELOPMENT OVERLAY — live source + zero-setup secrets
# =============================================================================
# Layered ON TOP of compose.yml. This overlay is what turns the frozen base
# stack into an actual dev environment. It adds two things compose.yml omits:
#
# 1. Source bind-mounts + the dev platform image (`build.target: dev`) — host
# edits reach the running stack without an image rebuild. The platform
# entrypoint (NODE_ENV=development; see docker-entrypoint.sh) runs a
# `vite build --watch` watcher so a browser refresh shows frontend
# (app/, lib/) changes. Opt out with TALE_DEV_HOT_RELOAD=0. Backend
# changes still need an image rebuild — for a live backend loop use
# host `cd services/platform && bun dev`.
# NOTE: this is hard-refresh, not Vite HMR — no React Fast Refresh / state
# retention. For true HMR use host `cd services/platform && bun dev`.
# 2. Insecure dev secret defaults (the `x-dev-secrets` anchor below) — so the
# stack boots with NO .env at all. A real .env still wins (the `${VAR:-…}`
# fallbacks only fill gaps; compose auto-loads .env for interpolation).
#
# Usage (recommended):
# bun run docker:dev
# = docker network inspect tale-sandbox-net || docker network create \
# --internal --ipv6=false --driver=bridge tale-sandbox-net
# docker compose -f compose.yml -f compose.dev.yml -f compose.docs.yml \
# up --build
# Prefer the npm script: it first ensures the external `tale-sandbox-net` (the
# `sandbox` network is `external: true` in compose.yml; a raw `docker compose up`
# fails with "network ... declared as external, but could not be found" because
# only the CLI / this script create it — mirrors dev-engine.ts ensureSandboxNetwork).
# compose.docs.yml is required: this file carries a `docs` override whose base
# service lives only in compose.docs.yml — omit it and compose rejects the whole
# project ("docs has neither an image nor a build context"). It does not force
# the docs site to run. (Same chain as docs/.../docker-compose-reference.)
#
# Never used by `tale deploy` (production) — these insecure defaults can't leak
# into a real deployment.
# =============================================================================
# -----------------------------------------------------------------------------
# Dev-only secret defaults. Mirrors services/platform/scripts/dev-secrets.ts
# (the `bun dev` path) so both local modes share the SAME insecure-but-stable
# keys — guardrails secret-box rows encrypted under one mode still decrypt under
# the other. Injected into every secret-consuming service via `<<: *dev-secrets`.
# Each value is `${VAR:-default}`: an env var or .env entry overrides it.
# -----------------------------------------------------------------------------
x-dev-secrets: &dev-secrets
HOST: ${HOST:-localhost}
SITE_URL: ${SITE_URL:-https://localhost}
TLS_MODE: ${TLS_MODE:-selfsigned}
DB_PASSWORD: ${DB_PASSWORD:-tale_dev_password}
KNOWLEDGE_DB_NAME: ${KNOWLEDGE_DB_NAME:-tale_knowledge}
# The deployment marker every app-side key derivation hangs off. Pinned to
# sha256("local-dev-insecure-secret") so this stack and `bun dev` derive the
# SAME keys; the 64-char hex shape is kept from the retired Convex tier so an
# existing dev .env keeps working unchanged.
INSTANCE_SECRET: ${INSTANCE_SECRET:-053357d69240558849ba1a091523807e06fe933d11346ab8127d5c0cd6743f64}
# No container-side derivation for these two — must be supplied explicitly.
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:-local-dev-better-auth-secret-do-not-use-in-prod-0123456789abcdef}
# Pinned to sha256("local-dev-insecure-secret:encryption-secret:v1"), the value
# dev-secrets.ts ensureEncryptionSecret() derives — set explicitly (not from the
# hex INSTANCE_SECRET above) so guardrails secret-box rows stay decryptable
# across `bun dev` and this docker stack.
ENCRYPTION_SECRET_HEX: ${ENCRYPTION_SECRET_HEX:-7a7059df10c10d68ee89d73567ebdf4ecc4b94f1cab14f7b430dffce9562bd53}
# Stable dev pepper so failed sign-ins reach the audit log as hashes, the
# way a `tale init` deployment writes them; absent → plaintext email + IP
# and a [SECURITY] warning at the first write. Rotate for production.
TALE_AUDIT_PEPPER: ${TALE_AUDIT_PEPPER:-9c1e5b7d3a2f8064e1c7a9d5b3f2e8c604a7d1b9e5c3f8a2d6b0e4c7a1f9d3b5}
# The sandbox control plane fails closed without these two: the spawner
# refuses to boot without SANDBOX_TOKEN (it holds the docker socket and sits
# on the network every session container shares), and the backend refuses
# every LLM-gateway management call without the admin password (the gateway
# shares one port for inference and /api/* on that same network). Same
# literals as services/platform/scripts/dev-secrets.ts so a host `bun dev`
# backend and this dockerized spawner / gateway share ONE HMAC key and ONE
# admin credential (dev-secrets.test.ts pins the lockstep). The gateway
# stores the password's hash in its volume, so the value must stay stable.
SANDBOX_TOKEN: ${SANDBOX_TOKEN:-local-dev-insecure-sandbox-token-do-not-use-in-prod-0123456789abcdef}
SANDBOX_LLM_GATEWAY_ADMIN_PASSWORD: ${SANDBOX_LLM_GATEWAY_ADMIN_PASSWORD:-Local-dev-insecure-gateway-admin-password-1}
services:
db:
environment:
<<: *dev-secrets
DB_LOG_STATEMENT: all
DB_LOG_MIN_DURATION_STATEMENT: '0'
knowledge-db:
environment:
<<: *dev-secrets
# The backend tier gets the dev secrets and runs with NODE_ENV=development
# (dev-only lanes gate on it).
# `bun dev` runs the backend on the HOST, so the blob store needs a
# published port — the internal `object-store:9000` address only exists
# inside the compose network. Same keys as the compose.yml dev defaults, so
# both local modes address one bucket.
object-store:
ports:
- '${OBJECT_STORE_HOST_PORT:-59000}:9000'
backend-api:
environment:
<<: *dev-secrets
NODE_ENV: development
backend-worker:
environment:
<<: *dev-secrets
NODE_ENV: development
# `bun dev` runs the backend on the HOST, but a sandbox session container
# sits on the --internal sandbox net with no host route and its undici fetch
# ignores the egress proxy — it can only reach hosts ON that network. This
# socat bridge carries the `backend-api` alias there and forwards to the
# host's api port, so the in-container tool + connector bridges reach the
# same doors they reach in production.
backend-relay:
image: alpine/socat
entrypoint: ['/bin/sh', '-c']
command:
- >-
socat TCP-LISTEN:3005,fork,reuseaddr TCP:host.docker.internal:3005 &
wait
extra_hosts:
- 'host.docker.internal:host-gateway'
restart: unless-stopped
networks:
internal: {}
sandbox:
aliases:
- backend-api
platform:
# Build the dev image (Dockerfile `dev` stage): the unpruned builder with
# vite + the rolldown bundler + full frontend source, so the entrypoint can
# run `vite build --watch` against the host source mounted below. The
# default (prod) target is a pruned runtime that has neither. See
# compose.yml for the base build config.
build:
target: dev
volumes:
# These mounts overlay the dev image's monorepo layout
# (/app/services/platform/*), so host edits reach the running watcher:
# app/ + lib/ are rebuilt into dist/ by `vite build --watch`; a browser
# refresh shows the change (hard reload, no HMR).
- ./services/platform/app:/app/services/platform/app
- ./services/platform/lib:/app/services/platform/lib
# The org config store — see the volume note in compose.yml for the
# one-time copy out of the retired `convex-data` volume.
- config-data:/app/data:ro
environment:
<<: *dev-secrets
NODE_ENV: development
# Master switch for the frontend hot-reload watcher, default on in dev.
# Set to 0 to serve the static prebuilt dist/ only.
TALE_DEV_HOT_RELOAD: ${TALE_DEV_HOT_RELOAD:-1}
# Auto-seed a ready-to-log-in dev account on boot (default on in this
# dev overlay only): dev@tale.test / TaleDev!Passw0rd owning a
# scaffolded "Dev Workspace" org — a fresh stack needs no manual /setup
# pass before testing. Set TALE_DEV_SEED_USER=0 to opt out (the /setup
# wizard then appears as before); override the identity via
# TALE_DEV_SEED_USER_EMAIL / TALE_DEV_SEED_USER_PASSWORD. The seeder
# (services/platform/backend/domains/provisioning/dev-seed.ts, run from
# the backend boot sequence) additionally refuses to run when SITE_URL is
# not a loopback host, so an accidental carry-over into a reachable
# deployment stays inert. Never used by `tale deploy` (production ignores
# this overlay).
TALE_DEV_SEED_USER: ${TALE_DEV_SEED_USER:-1}
# The seeded account above means this stack is never empty, and a real
# deployment closes `/sign-up/email` once it holds one
# (services/platform/backend/auth/sign-up-gate.ts). A dev stack still
# needs the route — save-auth-state.ts and the docs screenshots mint
# their own owners over it — so this overlay, and only this overlay,
# opts in. Set TALE_ALLOW_OPEN_SIGN_UP=0 to rehearse the refusal.
TALE_ALLOW_OPEN_SIGN_UP: ${TALE_ALLOW_OPEN_SIGN_UP:-true}
docs:
volumes:
- ./services/docs/app:/app/services/docs/app
- ./services/docs/lib:/app/services/docs/lib
- ./services/docs/messages:/app/services/docs/messages
- ./services/docs/scripts:/app/services/docs/scripts
environment:
<<: *dev-secrets
NODE_ENV: development
proxy:
environment:
<<: *dev-secrets
# When the backend runs on the HOST (`cd services/platform && bun dev`
# instead of the dockerized `backend-api` service), the spawner container
# needs to reach http://host.docker.internal:3005 for the EP1/EP2 callbacks.
# Linux Docker doesn't add this DNS alias by default; the line below opts in.
# In that bun-dev setup, also set in `services/platform/.env.local` so the
# blob stage URLs handed to a session resolve to the host-run backend:
# SANDBOX_HTTP_API_BASE_URL=http://host.docker.internal:3005
sandbox:
extra_hosts:
- 'host.docker.internal:host-gateway'
# compose.yml only reads SANDBOX_TOKEN from the optional .env, and the
# spawner refuses to boot without it — the anchor's dev default keeps the
# no-.env dev stack bootable (and in lockstep with the host backend).
environment:
<<: *dev-secrets
# A fresh gateway creates its first admin account only for the setup token
# its image derives from SANDBOX_LLM_GATEWAY_ADMIN_PASSWORD, and compose.yml
# gives it that password only from the optional .env — the anchor's dev
# default lets the backend claim the no-.env dev stack's gateway with the
# same literal it signs in with.
sandbox-llm-gateway:
environment:
<<: *dev-secrets