fix(config): override host when deployed to docker#403
fix(config): override host when deployed to docker#403jamiepine merged 3 commits intospacedriveapp:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds test coverage and a TOML-schema adjustment so when SPACEBOT_DEPLOYMENT is set to "docker" the API bind is forced to "0.0.0.0"; two tests exercise TOML parsing and env-default loading to validate this behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| @@ -113,7 +113,12 @@ pub(super) fn default_api_bind() -> String { | |||
|
|
|||
| pub(super) fn hosted_api_bind(bind: String) -> String { | |||
| match std::env::var("SPACEBOT_DEPLOYMENT") { | |||
There was a problem hiding this comment.
For docker, do we want 0.0.0.0 (matches docs/docker.md + avoids IPv6-disabled hosts) instead of [::]? Something like:
| match std::env::var("SPACEBOT_DEPLOYMENT") { | |
| match std::env::var("SPACEBOT_DEPLOYMENT") { | |
| Ok(deployment) if deployment.eq_ignore_ascii_case("hosted") => "[::]".into(), | |
| Ok(deployment) if deployment.eq_ignore_ascii_case("docker") => "0.0.0.0".into(), | |
| _ => bind, | |
| } |
There was a problem hiding this comment.
The decision to use 0.0.0.0 is, like you said, because not every Cloud host offers IPv6. If the user wants IPv6 they can override the deployment ourselves. I can't make any assumptions about the hosted infrastructure, but I do know a lot about Docker.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/config/toml_schema.rs`:
- Around line 114-121: The function hosted_api_bind currently returns "[::]" for
Docker/hosted deployments which contradicts the docs and can cause IPv6-only
binding; update hosted_api_bind to return "0.0.0.0" for the Docker/hosted branch
(or alternatively implement explicit dual-stack socket configuration and
document it) so that Docker deployments match the documented IPv4 binding;
locate the hosted_api_bind function and replace the "[::]".into() result for the
deployment.eq_ignore_ascii_case("hosted") ||
deployment.eq_ignore_ascii_case("docker") branch with "0.0.0.0".into() (or add
socket option handling if you choose the dual-stack approach) to resolve the
discrepancy.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c6a57ddc-e502-4049-977a-86d3a947081e
📒 Files selected for processing (2)
src/config.rssrc/config/toml_schema.rs
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/config/toml_schema.rs (1)
114-118: Consider sharing deployment detection instead of matching env strings here.This fixes the Docker branch, but
hosted_api_bind()still re-implements deployment parsing that already exists insrc/update.rs::Deployment::detect(). Reusing a shared helper would reduce the chance of this drifting again and keep bind behavior aligned with the container fallback logic there.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/config/toml_schema.rs` around lines 114 - 118, Replace the ad-hoc environment string match in hosted_api_bind with a call to the shared deployment-detection helper (use Deployment::detect() from src/update.rs) so bind behavior follows the same logic; update hosted_api_bind to consult Deployment::detect() and return "[::]" for Deployment::Hosted, "0.0.0.0" for Deployment::Docker (or the equivalent enum variants), otherwise return the provided bind string, ensuring you import or reference the Deployment type/constructor as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/config/toml_schema.rs`:
- Around line 114-118: Replace the ad-hoc environment string match in
hosted_api_bind with a call to the shared deployment-detection helper (use
Deployment::detect() from src/update.rs) so bind behavior follows the same
logic; update hosted_api_bind to consult Deployment::detect() and return "[::]"
for Deployment::Hosted, "0.0.0.0" for Deployment::Docker (or the equivalent enum
variants), otherwise return the provided bind string, ensuring you import or
reference the Deployment type/constructor as needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c66f02e3-de5e-4ae0-8a2d-690b00e7976f
📒 Files selected for processing (2)
src/config.rssrc/config/toml_schema.rs
Fixes #242
I added the
dockerSPACEBOT_DEPLOYMENTthat was expected to be in a few places but wasn't.There is still a floating
SPACEBOT_DEPLOYMENT=nixosbut I don't use Nix and I don't know what it was meant to do. It seems to just be being defined.On
dockerhosts, we bind to0.0.0.0instead of[::]because while we (assumedly) know for certain what the hosted environment is, not every host offers IPv6 to Docker containers. v6 only is significantly rarer than v4 only, and v6 only users (with proper documentation) can modify the bind themselves.Note
This PR adds Docker deployment support to the configuration system by ensuring the API bind address is correctly overridden to
[::](listening on all interfaces) whenSPACEBOT_DEPLOYMENT=dockeris set. The changes include updates to thehosted_api_bind()function to recognize the "docker" deployment type alongside the existing "hosted" type, plus comprehensive test coverage for both TOML configuration and environment-based defaults.Written by Tembo for commit cf07234.