Files
bot-bottle/bot_bottle/backend/docker/sidecar_bundle.py
T
didericis 96b84eb84d
lint / lint (push) Successful in 2m19s
test / unit (pull_request) Successful in 1m14s
test / integration (pull_request) Successful in 32s
test / coverage (pull_request) Successful in 1m28s
refactor(orchestrator): split conflated sidecar image into orchestrator + gateway images
One image — `bot-bottle-sidecars:latest`, built from `Dockerfile.sidecars` —
served two unrelated roles: the egress/git-gate/supervise *data plane* and
the orchestrator *control plane* (which ran the same image with the entrypoint
overridden to `python3 -m bot_bottle.orchestrator`). The control plane is
stdlib-only, so it needed none of the mitmproxy/git/gitleaks payload it was
riding on — while being the most secret-dense process on the host (PRD 0070's
"secret concentration").

Split into two purpose-built images:

- `Dockerfile.gateway` -> `bot-bottle-gateway:latest` — the data plane
  (renamed from Dockerfile.sidecars; identical contents).
- `Dockerfile.orchestrator` -> `bot-bottle-orchestrator:latest` — a lean
  `python:3.12-slim` runtime; the bind-mounted `bot_bottle` package supplies
  the code (so the #381 source-hash recreate semantics are unchanged).

`OrchestratorService` now takes distinct `image` (control plane, default
`ORCHESTRATOR_IMAGE`) and `gateway_image` (data plane, default `GATEWAY_IMAGE`)
instead of feeding one `self.image` to both, and builds the lean image
(build-if-missing) before starting the container. The per-bottle bundle
constants in `backend/docker/sidecar_bundle.py` now alias the gateway
constants so a bundle and the shared gateway can never drift onto different
images. The `bot-bottle-sidecars` *image* name and `Dockerfile.sidecars` are
gone; the per-bottle *container* name prefix (`bot-bottle-sidecars-<slug>`) is
intentionally left for a separate change.

Verified end-to-end: both images build; the lean image runs the control plane;
`ensure_running` brings up the orchestrator on `bot-bottle-orchestrator:latest`
and the gateway on `bot-bottle-gateway:latest` (distinct images) and reports
healthy.

Closes #384.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBMWTEtQdJ4W5UrWuLHCck
2026-07-14 16:24:16 -04:00

34 lines
1.4 KiB
Python

"""Sidecar bundle constants + helpers for the Docker backend
(PRD 0024).
A per-bottle sidecar bundle runs egress + git-gate + supervise as one
container under a small Python init supervisor. As of PRD 0024 chunk 5
the bundle is the only shape — the legacy four-sidecar topology and its
`BOT_BOTTLE_SIDECAR_BUNDLE` feature flag are gone.
The bundle's image is the **same data plane** as the consolidated
per-host gateway (PRD 0070), so it is one image with one name and one
Dockerfile: `bot-bottle-gateway` / `Dockerfile.gateway` (#384). These
constants alias the gateway's so a per-bottle bundle and the shared
gateway can never drift onto different images."""
from __future__ import annotations
from ...orchestrator.gateway import GATEWAY_DOCKERFILE, GATEWAY_IMAGE
# The per-bottle bundle image == the gateway data-plane image (aliased so
# there is one source of truth; the `BOT_BOTTLE_GATEWAY_IMAGE` env override
# on the gateway constant applies here too).
SIDECAR_BUNDLE_IMAGE = GATEWAY_IMAGE
SIDECAR_BUNDLE_DOCKERFILE = GATEWAY_DOCKERFILE
def sidecar_bundle_container_name(slug: str) -> str:
"""`bot-bottle-sidecars-<slug>`. Same prefix scheme as the
per-sidecar containers it replaces, so the dashboard's
discovery-by-prefix logic keeps working. (The per-bottle *container*
name keeps the historical `sidecars-` prefix; only the *image* was
renamed to `bot-bottle-gateway` in #384.)"""
return f"bot-bottle-sidecars-{slug}"