Skip to content

fix(docker): require auth secrets in prod and Ollama Compose files#5806

Open
waleedlatif1 wants to merge 3 commits into
stagingfrom
worktree-fix-ollama-compose-secrets
Open

fix(docker): require auth secrets in prod and Ollama Compose files#5806
waleedlatif1 wants to merge 3 commits into
stagingfrom
worktree-fix-ollama-compose-secrets

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Builds on #5801 (included as the first commit) and closes the remaining gap in that fix: the same first-user-signup failure still exists in docker-compose.ollama.yml, which many self-hosters use because it's the "try Sim with local models" path.

Root cause (the part #5801 didn't cover)

docker-compose.ollama.yml fell back to broken secret defaults:

  • BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-sim_auth_secret_$(openssl rand -hex 16)} and ENCRYPTION_KEY=${ENCRYPTION_KEY:-$(openssl rand -hex 32)}Docker Compose does not perform $(...) command substitution, so these resolve to the literal strings, i.e. a fixed, shared, weak secret across every install. Worse, the ENCRYPTION_KEY literal ($(openssl rand -hex 32), 22 chars) is under the 32-char minimum the app enforces (z.string().min(32)), so it fails env validation.
  • INTERNAL_API_SECRET — required (z.string().min(32)) by both the app (apps/sim/lib/core/config/env.ts) and realtime (apps/realtime/src/env.ts) — was not passed at all, so the Ollama quick start couldn't sign up the first admin, exactly like the prod bug in [BUG] signup first admin account fails in docker compose #5625.

Changes

  • Mirror the prod hardening in docker-compose.ollama.yml: require BETTER_AUTH_SECRET, ENCRYPTION_KEY, and INTERNAL_API_SECRET via mandatory ${VAR:?...} interpolation, and add INTERNAL_API_SECRET to both simstudio and realtime.
  • Extend the regression test to assert the mandatory-secret interpolation for both docker-compose.prod.yml and docker-compose.ollama.yml.
  • Note the .env prerequisite in the Ollama section of the docs (en/de/es/fr/ja/zh) and CONTRIBUTING.

Validation

  • vitest run lib/core/config/docker-compose-secrets.test.ts — 10 passed (5 prod + 5 ollama; the test parses the real Compose files).
  • biome check on the test file — passed.
  • Both Compose files parse as valid YAML (loaded by the test via js-yaml).

Credit

First commit is @brainx's original #5801. This PR supersedes it — merging this lands both fixes together.

Fixes #5625

brainx and others added 2 commits July 21, 2026 19:48
The Ollama Compose file fell back to broken defaults: docker compose does
not perform $(...) command substitution, so BETTER_AUTH_SECRET and
ENCRYPTION_KEY resolved to literal, shared, weak values (and the
ENCRYPTION_KEY literal was under the 32-char minimum the app enforces).
INTERNAL_API_SECRET — required (min 32) by both the app and realtime — was
not passed at all, so first-user signup failed the same way prod did.

Mirror the prod hardening: require BETTER_AUTH_SECRET, ENCRYPTION_KEY, and
INTERNAL_API_SECRET via mandatory ${VAR:?...} interpolation, add
INTERNAL_API_SECRET to both services, extend the regression test to cover
the Ollama Compose file, and note the .env prerequisite in the docs.
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 21, 2026 6:46pm

Request Review

@cursor

cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes affect how all Docker self-hosters must configure secrets at startup; misconfiguration now blocks compose instead of silently using invalid defaults, which is safer but is a breaking change for installs that relied on old Ollama fallbacks.

Overview
Docker Compose now fails fast unless BETTER_AUTH_SECRET, ENCRYPTION_KEY, and INTERNAL_API_SECRET are set in .env, using mandatory ${VAR:?...} interpolation on docker-compose.prod.yml and docker-compose.ollama.yml for simstudio and realtime. The Ollama stack drops broken defaults that treated $(openssl …) as literal strings (weak/shared secrets and env validation failures) and adds INTERNAL_API_SECRET to both services so the local-models path matches prod auth requirements.

Self-hosting docs (README, CONTRIBUTING, and Docker guides in en/de/es/fr/ja/zh) now walk through a one-time .env secret bootstrap (refuse overwrite, backup warnings, append-only migration for older installs) and call out that Ollama Compose needs the same secrets before start.

A Vitest regression (docker-compose-secrets.test.ts) asserts both compose files wire those variables through mandatory interpolation.

Reviewed by Cursor Bugbot for commit 41f1fef. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens secret handling for production and Ollama Docker deployments. The main changes are:

  • Requires persistent authentication, encryption, and internal API secrets.
  • Passes the internal API secret to both application services.
  • Adds tests for mandatory Compose interpolation.
  • Documents secret creation, backup, and migration across all Docker guides.

Confidence Score: 5/5

This looks safe to merge.

  • No additional blocking issues qualify for this follow-up review.

Important Files Changed

Filename Overview
docker-compose.prod.yml Requires authentication, encryption, and internal API secrets for production services.
docker-compose.ollama.yml Removes invalid fallback secrets and supplies the internal API secret to both Ollama services.
apps/sim/lib/core/config/docker-compose-secrets.test.ts Checks mandatory secret interpolation in both production and Ollama Compose files.
README.md Documents persistent secret generation, backup, and migration for Docker installations.

Reviews (3): Last reviewed commit: "docs(docker): add upgrade path for insta..." | Re-trigger Greptile

Comment thread README.md
The generation block refuses to overwrite an existing .env, so an
installation that predates the newly required secrets had no documented
way to add them before the hardened Compose files fail-fast on startup.
Add an idempotent snippet that appends only the missing secrets while
preserving existing values, across the README, contributor guide, and all
localized Docker guides.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes production and Ollama deployments require persistent secrets. The main changes are:

  • Require authentication, encryption, and internal API secrets in both Compose files.
  • Pass the internal API secret to the application and realtime services.
  • Add tests for mandatory secret interpolation.
  • Document secure .env generation and backup across self-hosting guides.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • Required values are passed consistently to both services.
  • The documented setup generates every newly required secret.

Important Files Changed

Filename Overview
docker-compose.prod.yml Requires production secrets with actionable Compose interpolation errors.
docker-compose.ollama.yml Removes broken secret defaults and supplies the internal API secret to both services.
apps/sim/lib/core/config/docker-compose-secrets.test.ts Checks mandatory secret interpolation in both production Compose variants.
README.md Adds secure one-time secret generation and persistence guidance.
.github/CONTRIBUTING.md Aligns contributor setup instructions with the required Compose secrets.
apps/docs/content/docs/en/platform/self-hosting/docker.mdx Updates the self-hosting and Ollama setup flow for persistent secrets.

Reviews (2): Last reviewed commit: "docs(docker): add upgrade path for insta..." | Re-trigger Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 41f1fef. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants