From 232dfdf37ac898019e996d754dd9b1e286163337 Mon Sep 17 00:00:00 2001 From: claude Date: Sat, 18 Jul 2026 07:59:57 +0000 Subject: [PATCH] refactor(gateway): replace egress_addon.py copy with a one-line shim mitmdump -s requires a file path, not a module. Instead of copying the full egress_addon.py to /app/, write a one-line shim at image build time that re-exports addons from the installed package. mitmdump finds the addons list in the shim's namespace; all real addon code stays in bot_bottle/egress_addon.py. --- Dockerfile.gateway | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile.gateway b/Dockerfile.gateway index 604edbf..74c8c24 100644 --- a/Dockerfile.gateway +++ b/Dockerfile.gateway @@ -19,7 +19,8 @@ # /app/egress_addon.py mitmproxy addon entry point # /app/egress-entrypoint.sh mitmdump launcher # /usr/local/lib/python*/bot_bottle/ installed package (all daemons + shared modules) -# /app/egress_addon.py mitmdump addon (file path required by -s flag) +# /app/egress_addon.py one-line shim: re-exports addons from package +# (mitmdump -s requires a file path, not a module) # /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 @@ -95,11 +96,9 @@ COPY pyproject.toml /src/ COPY bot_bottle/ /src/bot_bottle/ RUN pip install --no-cache-dir /src/ -# 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 +# mitmdump -s requires a file path, not a module. Write a one-line shim that +# re-exports `addons` from the installed package; mitmdump finds it there. +RUN printf 'from bot_bottle.egress_addon import addons\n' > /app/egress_addon.py COPY bot_bottle/egress_entrypoint.sh /app/egress-entrypoint.sh RUN chmod +x /app/egress-entrypoint.sh