fix(docker): forward OPENROUTER_API_KEY into the self-host container - #152
Merged
bensenescu merged 2 commits intoJul 30, 2026
Merged
Conversation
`.env.example` documents `OPENROUTER_API_KEY` as "Required if you want AI features like SAM", the in-app help page walks through creating one, and `SamSetupGate` tells the user to set the environment variable and restart. None of that works under Docker: Compose only forwards the keys listed under `environment:` in `compose.yaml`, and this one was missing, so `getEnvValueSync(this.env, "OPENROUTER_API_KEY")` in SamChatAgent never saw a value no matter what the user put in `.env`. Add the passthrough alongside the existing optional GSC keys. Verified with `docker compose config` against a `.env` containing the key: it is absent from the rendered config on main and present after this change. Also correct the sentence in SELF_HOSTING_DOCKER.md that says Compose "passes `.env` values into the container" — it only passes the ones `compose.yaml` lists, which is what made this easy to miss — and add the key to the optional env values list.
sorcerai
approved these changes
Jul 28, 2026
sorcerai
left a comment
There was a problem hiding this comment.
Reviewed exact current diff. OPENROUTER_API_KEY is forwarded without logging or changing defaults, and the Docker documentation now matches Compose behavior.
|
Integration note: #52 and this PR both touch compose.yaml and docs/SELF_HOSTING_DOCKER.md; merging either second conflicts. Safest order is #52 first, then rebase this small PR. While rebasing, please take up your offer from the PR body and add CHAT_BASE_URL passthrough for #115 so local/OpenAI-compatible chat also works under Docker. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OPENROUTER_API_KEYis documented as the key that unlocks the AI features on a self-hosted install:.env.example: "Optional in self-hosted modes. Required if you want AI features like SAM, the in-app SEO agent."src/routes/_app/help/openrouter-api-key.tsx— a whole in-app help page for obtaining and setting it.src/client/features/sam/SamSetupGate.tsx— tells the user to set theOPENROUTER_API_KEYenvironment variable and restart.Under Docker none of that has any effect. Compose only forwards the keys listed under
environment:incompose.yaml, and this one was not listed.SamChatAgent.ts:110callsgetEnvValueSync(this.env, "OPENROUTER_API_KEY"), gets nothing, and throwsOPENROUTER_API_KEY is required for the SAM agent— so the user follows the in-app instructions, restarts, and SAM stays broken with no indication why.Change
Add the passthrough next to the existing optional Google Search Console keys, using the same
${VAR:-}form so it stays optional.Verification
With a
.envcontainingOPENROUTER_API_KEY=sk-or-test123:pnpm ci:checkpasses.Docs
SELF_HOSTING_DOCKER.mdsaid Compose "passes.envvalues into the container", which reads as though any key in.envarrives in the container — the assumption that makes this bug easy to miss. Corrected to say it forwards the keyscompose.yamllists, and addedOPENROUTER_API_KEYto the optional env values list.Note
#115 adds
CHAT_BASE_URLfor local/OpenAI-compatible chat models. If that lands, it will need the same passthrough line to work under Docker — happy to add it here or leave it to that PR, whichever the maintainers prefer.