Consolidate infra backend for docker #431
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We originally separated the gateway from the orchestrator to lower the surface area of things to secure around the secrets, but we backed out of that due to overhead and complexity issues on both the macos container and the firecracker backend, and because we can't really afford either to be compromised the same way we can afford an issue in the agent/they both need to remain secure.
For consistency we should create an infra image and run a single infra container on the docker backend as well. Evaluate whether or not creating a shared docker imagefile also makes sense. Probably, but there's an argument for keeping it separate so it's easier to read and maintain/the orchestrator needs remain conceptually separate from the gateway needs.
Looking at the current docker slice:
OrchestratorService.ensure_runningstarts two containers —bot-bottle-orch-gatewayfromDockerfile.gatewayandbot-bottle-orchestratorfromDockerfile.orchestrator— and wires them together on the shared network. The firecracker backend has the consolidated pattern already (gateway + orchestrator content in one image, supervised bygateway_init). This would mirror that.On the shared Dockerfile question: I lean yes, with a layered model:
Dockerfile.infra= gateway + orchestrator (docker infra, no buildah) — currently this is firecracker-only but the gateway/orchestrator combination is what both backends needFROM bot-bottle-infra+ buildah/crun/netavarkDockerfile.orchestratorstays as the single canonical orchestrator content definition (still referenced viaCOPY --from)That makes the split explicit by layer rather than by filename, and firecracker gets its builder without duplicating the base.
One open question before I start: should the orchestrator join the gateway's
gateway_initsupervise tree (so a single entrypoint manages both), or run as a sibling CMD alongside it? Thegateway_initpath seems cleaner since restart/health logic is already there — but it changes how thesource_hashlive-reload detect would work (currentlyOrchestratorServicerecreates the container on a code change; with a combined container we'd recreate the whole thing, which also bounces the gateway and drops in-flight egress connections). That may be acceptable given this is a dev-only concern, but worth confirming.If the supervise-tree approach is the right call, I'll proceed with: (1) restructure
Dockerfile.infraas the shared gateway+orchestrator base, (2) add orchestrator togateway_initsupervision, (3) updateOrchestratorServiceto start onebot-bottle-infracontainer, (4) update firecracker toFROM bot-bottle-infra+ buildah.@didericis-claude supervise-tree is the right approach. Also look for opportunities to consolidate logic between macos container, firecracker, and docker backends, as they should all be using the same structure now.
Got it. Mapping out what I see across the three backends before writing the PRD.
Dockerfile restructuring plan:
Dockerfile.infrabecomes the shared base:FROM bot-bottle-gateway+COPY --from bot-bottle-orchestrator(no buildah, that's Firecracker-only)Dockerfile.infra.fc(or similar) that doesFROM bot-bottle-infra+ buildah/crun/netavark — same net result, just now layered from the shared baseDockerfile.orchestratorstays as the canonical orchestrator content definition (nothing changes there)Supervise-tree: orchestrator process added to
gateway_init,OrchestratorServicestarts onebot-bottle-infracontainer instead of two.Consolidation opportunities I see:
consolidated_launch.pyfiles. Move to a shared utility.OrchestratorClient.teardown_bottle+deprovision_git_gate(transport, bottle_id); could be a shared helper that accepts a transport.consolidated_launch.pyshape — all three follow ensure-infra → allocate/register → provision → return context; macOS inverts the allocation timing (DHCP, source IP known only after agent runs) but the rest is the same. This is probably worth extracting a shared skeleton, with the macOS DHCP inversion as the explicit override point.GatewayTransportprotocol +provision_git_gate/deprovision_git_gate). No change needed there.Irreducible differences I'll leave in place:
--ip; agent starts before registration)Will scope the PRD around these four items and open it once drafted.