refactor(gateway): replace egress_addon.py copy with a one-line shim
test / integration (pull_request) Successful in 1m15s
test / coverage (pull_request) Failing after 1m13s
test / unit (pull_request) Successful in 1m19s

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.
This commit is contained in:
2026-07-18 07:59:57 +00:00
parent 9a0dd821ef
commit 232dfdf37a
+5 -6
View File
@@ -19,7 +19,8 @@
# /app/egress_addon.py mitmproxy addon entry point # /app/egress_addon.py mitmproxy addon entry point
# /app/egress-entrypoint.sh mitmdump launcher # /app/egress-entrypoint.sh mitmdump launcher
# /usr/local/lib/python*/bot_bottle/ installed package (all daemons + 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) # /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/egress/routes.yaml bind-mounted at run time
# /etc/git-gate/pre-receive docker-cp'd at start time # /etc/git-gate/pre-receive docker-cp'd at start time
# /git-gate-entrypoint.sh 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/ COPY bot_bottle/ /src/bot_bottle/
RUN pip install --no-cache-dir /src/ RUN pip install --no-cache-dir /src/
# egress_addon.py is loaded by `mitmdump -s /app/egress_addon.py`; the -s # mitmdump -s requires a file path, not a module. Write a one-line shim that
# flag requires a file path, so it cannot use `python3 -m`. The shell # re-exports `addons` from the installed package; mitmdump finds it there.
# entrypoint that runs mitmdump is also a fixed-path script. All other RUN printf 'from bot_bottle.egress_addon import addons\n' > /app/egress_addon.py
# 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/egress_entrypoint.sh /app/egress-entrypoint.sh COPY bot_bottle/egress_entrypoint.sh /app/egress-entrypoint.sh
RUN chmod +x /app/egress-entrypoint.sh RUN chmod +x /app/egress-entrypoint.sh