From 9a0dd821efece74fa4a45fdc1f41c74c4e611e7f Mon Sep 17 00:00:00 2001 From: claude Date: Sat, 18 Jul 2026 07:55:38 +0000 Subject: [PATCH] refactor(gateway): invoke daemons via python3 -m instead of /app/ file copies supervise_server, git_http_backend, and gateway_init all have __main__ guards, so python3 -m bot_bottle.X replaces the individual COPY lines to /app/. egress_addon.py stays as a file copy because mitmdump -s requires a file path rather than a module reference. --- Dockerfile.gateway | 19 +++++++------------ bot_bottle/gateway_init.py | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Dockerfile.gateway b/Dockerfile.gateway index d9dbe57..604edbf 100644 --- a/Dockerfile.gateway +++ b/Dockerfile.gateway @@ -18,10 +18,8 @@ # /usr/bin/gitleaks gitleaks binary # /app/egress_addon.py mitmproxy addon entry point # /app/egress-entrypoint.sh mitmdump launcher -# /app/supervise_server.py supervise MCP server entry point -# /app/gateway_init.py PID 1 supervisor entry point -# /app/git_http_backend.py git-http entry point -# /usr/local/lib/python*/bot_bottle/ installed package (all shared modules) +# /usr/local/lib/python*/bot_bottle/ installed package (all daemons + shared modules) +# /app/egress_addon.py mitmdump addon (file path required by -s flag) # /etc/egress/routes.yaml bind-mounted at run time # /etc/git-gate/pre-receive docker-cp'd at start time # /git-gate-entrypoint.sh docker-cp'd at start time @@ -97,14 +95,11 @@ COPY pyproject.toml /src/ COPY bot_bottle/ /src/bot_bottle/ RUN pip install --no-cache-dir /src/ -# Entry-point scripts invoked by gateway_init.py. These live at /app/ -# so the supervisor, shell entrypoint, and ENTRYPOINT all reach them at -# known fixed paths. Their sibling imports all go through bot_bottle.* -# (the installed package above), not flat /app/ neighbours. +# egress_addon.py is loaded by `mitmdump -s /app/egress_addon.py`; the -s +# flag requires a file path, so it cannot use `python3 -m`. The shell +# entrypoint that runs mitmdump is also a fixed-path script. All other +# daemons are invoked via `python3 -m bot_bottle.X` and need no copy here. COPY bot_bottle/egress_addon.py /app/egress_addon.py -COPY bot_bottle/supervise_server.py /app/supervise_server.py -COPY bot_bottle/gateway_init.py /app/gateway_init.py -COPY bot_bottle/git_http_backend.py /app/git_http_backend.py COPY bot_bottle/egress_entrypoint.sh /app/egress-entrypoint.sh RUN chmod +x /app/egress-entrypoint.sh @@ -127,4 +122,4 @@ WORKDIR /app # PID 1 is the supervisor. It owns signal handling and exit-code # propagation; no `exec` chain in the entrypoint itself. -ENTRYPOINT ["python3", "/app/gateway_init.py"] +ENTRYPOINT ["python3", "-m", "bot_bottle.gateway_init"] diff --git a/bot_bottle/gateway_init.py b/bot_bottle/gateway_init.py index e91a7b8..083d7c8 100644 --- a/bot_bottle/gateway_init.py +++ b/bot_bottle/gateway_init.py @@ -78,8 +78,8 @@ def _env_for_daemon(name: str, base_env: dict[str, str]) -> dict[str, str]: _DAEMONS: tuple[_DaemonSpec, ...] = ( _DaemonSpec("egress", ("/bin/sh", "/app/egress-entrypoint.sh")), _DaemonSpec("git-gate", ("/bin/sh", "/git-gate-entrypoint.sh")), - _DaemonSpec("git-http", ("python3", "/app/git_http_backend.py")), - _DaemonSpec("supervise", ("python3", "/app/supervise_server.py")), + _DaemonSpec("git-http", ("python3", "-m", "bot_bottle.git_http_backend")), + _DaemonSpec("supervise", ("python3", "-m", "bot_bottle.supervise_server")), )