cd9f023f3d
prd-number-check / require-numbered-prds (pull_request) Successful in 11s
tracker-policy-pr / check-pr (pull_request) Successful in 14s
test / unit (pull_request) Successful in 59s
test / integration-docker (pull_request) Successful in 1m6s
test / coverage (push) Successful in 21s
test / image-input-builds (push) Successful in 44s
test / image-input-builds (pull_request) Successful in 1m15s
test / unit (push) Successful in 57s
test / coverage (pull_request) Successful in 20s
lint / lint (push) Successful in 1m3s
Update Quality Badges / update-badges (push) Successful in 1m12s
test / integration-docker (push) Successful in 1m0s
`doctor` told users to run `./cli.py backend setup`. cli.py is a four-line wrapper at the repo root that calls bot_bottle.cli:main, and it does not ship — [tool.setuptools.packages.find] includes only bot_bottle*, so anyone who installed rather than cloned has no such file. Confirmed against a real install: the user's tree contains exactly one executable, `bot-bottle`, and no cli.py anywhere, while doctor recommended `./cli.py` three times. Invisible in development, where ./cli.py works fine from a checkout, which is why only a clean-install test surfaced it. The two entry points are the same code, so the fix is to name the one that always exists. 141 replacements across 45 files: the runtime messages that caused this, plus README, docs, PRDs, research notes and test prose, so nothing teaches the invocation a user cannot run. scripts/demo.sh is deliberately untouched — it *executes* ./cli.py from a checkout, where that is the correct and available path. Verified end to end: a sandbox install now reports "Run: bot-bottle backend setup --backend=firecracker", and bot-bottle is on that user's PATH. Unit suite unchanged against the pre-existing baseline. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WEfZZhakx13bxTfXcZCoS5
94 lines
3.0 KiB
Python
94 lines
3.0 KiB
Python
"""Host setup + status for the Docker backend.
|
|
|
|
Unlike Firecracker, the Docker backend needs no privileged one-time
|
|
host provisioning (no TAP pool / nft table) — networks and the gateway
|
|
bundle are created per-launch. So `setup()` is mostly an install/daemon
|
|
pointer, and `status()` reports whether docker is usable.
|
|
|
|
This is intentionally minimal; a richer version (daemon config checks,
|
|
gVisor/runsc install guidance, rootless-docker hints) is tracked
|
|
separately. Reached via `DockerBottleBackend.setup` / `.status`, which
|
|
the generic `bot-bottle backend {setup,status}` dispatches to.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
from . import util as _util
|
|
|
|
|
|
def _docker_on_path() -> bool:
|
|
return shutil.which("docker") is not None
|
|
|
|
|
|
def _daemon_reachable() -> bool:
|
|
if not _docker_on_path():
|
|
return False
|
|
try:
|
|
return subprocess.run(
|
|
["docker", "info"],
|
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
|
check=False, timeout=5,
|
|
).returncode == 0
|
|
except subprocess.TimeoutExpired:
|
|
return False
|
|
|
|
|
|
def _print_install_pointer() -> None:
|
|
sys.stderr.write("Docker is required but was not found on PATH.\n")
|
|
sys.stderr.write(" macOS: Docker Desktop https://docs.docker.com/desktop/install/mac-install/\n")
|
|
sys.stderr.write(" Linux: Docker Engine https://docs.docker.com/engine/install/\n")
|
|
|
|
|
|
def setup() -> int:
|
|
if not _docker_on_path():
|
|
_print_install_pointer()
|
|
return 1
|
|
sys.stderr.write(
|
|
"Docker backend: no privileged host setup required — networks and "
|
|
"the gateway are created per-launch.\n"
|
|
)
|
|
if not _daemon_reachable():
|
|
sys.stderr.write(
|
|
"The Docker daemon isn't reachable; start it (e.g. Docker "
|
|
"Desktop, or `systemctl start docker`).\n"
|
|
)
|
|
return 1
|
|
if not _util.runsc_available():
|
|
sys.stderr.write(
|
|
"Optional: register the gVisor (`runsc`) runtime with Docker for "
|
|
"a userspace syscall barrier; bottles auto-detect and use it.\n"
|
|
)
|
|
return 0
|
|
|
|
|
|
def teardown() -> int:
|
|
sys.stderr.write(
|
|
"Docker backend: nothing to undo — it provisions no privileged host "
|
|
"state (networks and the gateway are per-launch and are "
|
|
"removed by `bot-bottle cleanup`). Docker itself is left installed.\n"
|
|
)
|
|
return 0
|
|
|
|
|
|
def status() -> int:
|
|
ok = True
|
|
if _docker_on_path():
|
|
sys.stderr.write("docker on PATH: yes\n")
|
|
else:
|
|
sys.stderr.write("docker on PATH: NO\n")
|
|
ok = False
|
|
if ok and _daemon_reachable():
|
|
sys.stderr.write("docker daemon: reachable\n")
|
|
elif ok:
|
|
sys.stderr.write("docker daemon: UNREACHABLE\n")
|
|
ok = False
|
|
runsc = _docker_on_path() and _util.runsc_available()
|
|
sys.stderr.write(f"gVisor runsc runtime: {'registered' if runsc else 'not registered (optional)'}\n")
|
|
if not ok:
|
|
sys.stderr.write("\nRun: bot-bottle backend setup --backend=docker\n")
|
|
return 0 if ok else 1
|