Skip to content

Commit 0c520bf

Browse files
fix(compose): forward NEXT_PUBLIC_CHAT_DISABLED to the app container
The wizard wrote the flag into the root .env, but compose only passes through variables the service's `environment` block names — and that block listed COPILOT_API_KEY without its companion. Skipping the chat key on a Docker install therefore did nothing: the value sat in .env and never reached the container. Add the passthrough to all four compose files. Reverts the previous commit's mirroring into apps/sim/.env, which treated the symptom — each mode writes only the env file it owns, and that file is now wired correctly. k8s needs no equivalent: its values flow into `app.env`, which the chart renders key by key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ErcRgvi7VQBeKDQ3MBMha
1 parent c5f45fe commit 0c520bf

8 files changed

Lines changed: 9 additions & 46 deletions

File tree

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
2020
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-your_encryption_key_here}
2121
- COPILOT_API_KEY=${COPILOT_API_KEY}
22+
- NEXT_PUBLIC_CHAT_DISABLED=${NEXT_PUBLIC_CHAT_DISABLED:-}
2223
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL}
2324
- OLLAMA_URL=${OLLAMA_URL:-http://localhost:11434}
2425
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-}

docker-compose.local.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ services:
2323
- INTERNAL_API_SECRET=${INTERNAL_API_SECRET:-dev-internal-api-secret-min-32-chars}
2424
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
2525
- COPILOT_API_KEY=${COPILOT_API_KEY:-}
26+
- NEXT_PUBLIC_CHAT_DISABLED=${NEXT_PUBLIC_CHAT_DISABLED:-}
2627
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL:-}
2728
- OLLAMA_URL=${OLLAMA_URL:-http://localhost:11434}
2829
- SOCKET_SERVER_URL=${SOCKET_SERVER_URL:-http://realtime:3002}

docker-compose.ollama.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-sim_auth_secret_$(openssl rand -hex 16)}
2020
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-$(openssl rand -hex 32)}
2121
- COPILOT_API_KEY=${COPILOT_API_KEY}
22+
- NEXT_PUBLIC_CHAT_DISABLED=${NEXT_PUBLIC_CHAT_DISABLED:-}
2223
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL}
2324
- OLLAMA_URL=http://ollama:11434
2425
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-}

docker-compose.prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ services:
3232
- INTERNAL_API_SECRET=${INTERNAL_API_SECRET}
3333
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
3434
- COPILOT_API_KEY=${COPILOT_API_KEY:-}
35+
- NEXT_PUBLIC_CHAT_DISABLED=${NEXT_PUBLIC_CHAT_DISABLED:-}
3536
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL:-}
3637
- OLLAMA_URL=${OLLAMA_URL:-http://localhost:11434}
3738
- SOCKET_SERVER_URL=${SOCKET_SERVER_URL:-http://realtime:3002}

scripts/setup/env-files.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,14 @@ export function upsertEnv(content: string, key: string, value: string): string {
105105
return lines.join('\n')
106106
}
107107

108-
/**
109-
* Writes values into an env file, seeding a missing file from its `.env.example`.
110-
*
111-
* `seedFromExample: false` creates a missing file holding only `values` instead.
112-
* Used when mirroring one flag into a target the user did not choose, where
113-
* materializing a whole example for a stack they are not running would be
114-
* surprising.
115-
*/
116-
export function writeEnvValues(
117-
target: EnvTarget,
118-
values: Record<string, string>,
119-
{ seedFromExample = true }: { seedFromExample?: boolean } = {}
120-
): void {
108+
/** Writes values into an env file, seeding a missing file from its .env.example. */
109+
export function writeEnvValues(target: EnvTarget, values: Record<string, string>): void {
121110
const filePath = ENV_PATHS[target]
122111
let content: string
123112
if (existsSync(filePath)) {
124113
content = readFileSync(filePath, 'utf8')
125114
} else {
126-
const example = seedFromExample ? EXAMPLE_PATHS[target] : undefined
115+
const example = EXAMPLE_PATHS[target]
127116
content = example && existsSync(example) ? readFileSync(example, 'utf8') : ''
128117
}
129118
for (const [key, value] of Object.entries(values)) {

scripts/setup/modes/compose.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
promptSignInProviders,
1818
promptStorage,
1919
promptUnlocks,
20-
writeAppBehaviorValues,
2120
} from '../steps.ts'
2221
import { glyph, theme } from '../theme.ts'
2322

@@ -114,7 +113,7 @@ export async function runComposeMode(detection: Detection, quick: boolean): Prom
114113
Object.assign(values, mothershipOverride())
115114
const copilotKey = await promptCopilotKey(root.vars.get('COPILOT_API_KEY'))
116115
if (copilotKey) values.COPILOT_API_KEY = copilotKey
117-
writeAppBehaviorValues('root', chatFlagValues(copilotKey))
116+
Object.assign(values, chatFlagValues(copilotKey))
118117
Object.assign(values, await promptLlmKeys(detection, !quick))
119118
if (!quick) {
120119
const storage = await promptStorage(root.vars, true)

scripts/setup/modes/dev.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
promptSignInProviders,
2020
promptStorage,
2121
promptUnlocks,
22-
writeAppBehaviorValues,
2322
} from '../steps.ts'
2423
import { glyph, theme } from '../theme.ts'
2524

@@ -126,7 +125,7 @@ export async function runDevMode(
126125
Object.assign(values, mothershipOverride())
127126
const copilotKey = await promptCopilotKey(simAfter.vars.get('COPILOT_API_KEY'))
128127
if (copilotKey) values.COPILOT_API_KEY = copilotKey
129-
writeAppBehaviorValues('sim', chatFlagValues(copilotKey))
128+
Object.assign(values, chatFlagValues(copilotKey))
130129
Object.assign(values, await promptLlmKeys(detection, !quick))
131130

132131
// Redis is set up in every mode, quick included. Storage falls back to

scripts/setup/steps.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import { browserKeyFlow } from './cli-auth.ts'
22
import type { Detection } from './detect.ts'
33
import {
44
type EnvFile,
5-
type EnvTarget,
65
generateSecret,
76
isPlaceholder,
87
isTruthy,
98
isUsableSecret,
109
SECRET_KEYS,
1110
secretRequirement,
12-
writeEnvValues,
1311
} from './env-files.ts'
1412
import * as p from './prompter.ts'
1513
import { link, theme } from './theme.ts'
@@ -82,32 +80,6 @@ export function chatFlagValues(copilotKey: string | null): Record<string, string
8280
return { NEXT_PUBLIC_CHAT_DISABLED: copilotKey ? 'false' : 'true' }
8381
}
8482

85-
/**
86-
* Env files the app reads its own configuration from: `apps/sim/.env` when
87-
* started with `bun run dev`, the root `.env` when started through
88-
* docker-compose.
89-
*/
90-
const APP_ENV_TARGETS = ['sim', 'root'] as const satisfies readonly EnvTarget[]
91-
92-
/**
93-
* Writes values that change how the app behaves — as opposed to where it
94-
* connects — to every env file the app might be started from, so the outcome
95-
* follows what the user answered rather than which command they later use to
96-
* launch Sim. Connection settings must NOT go through this: `DATABASE_URL` and
97-
* friends legitimately differ between the compose stack and a local dev run.
98-
*
99-
* Mirrored targets are written even when absent, because the file being missing
100-
* is precisely the case that strands the flag — but without seeding from
101-
* `.env.example`, so a compose run leaves behind a one-line `apps/sim/.env`
102-
* rather than a full example for a stack the user is not running.
103-
*/
104-
export function writeAppBehaviorValues(primary: EnvTarget, values: Record<string, string>): void {
105-
writeEnvValues(primary, values)
106-
for (const target of APP_ENV_TARGETS) {
107-
if (target !== primary) writeEnvValues(target, values, { seedFromExample: false })
108-
}
109-
}
110-
11183
/**
11284
* Escape hatch for Sim devs pointing an install at a non-prod mothership:
11385
*

0 commit comments

Comments
 (0)