feat: Add mitmproxy to the devcontainer - #7956
Conversation
486ec7c to
3fa3eac
Compare
There was a problem hiding this comment.
Pull request overview
Adds mitmproxy support to the repository devcontainer so contributors can run scripts/proxy_lp.py to serve locally built CSS/JS into the live Liquipedia site during development.
Changes:
- Install a pinned
mitmproxyversion into the devcontainer’s Python venv. - Persist mitmproxy’s CA state across rebuilds via a dedicated named volume.
- Forward port 8080 and document the local proxy workflow in the README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README.md | Documents the mitmproxy-based workflow for previewing locally built CSS/JS on the live wiki. |
| .devcontainer/post-create.sh | Adjusts ownership for the new ~/.mitmproxy named volume alongside node_modules. |
| .devcontainer/Dockerfile | Installs mitmproxy (pinned) into the devcontainer Python venv at image build time. |
| .devcontainer/devcontainer.json | Adds a named volume for ~/.mitmproxy and forwards port 8080 with port metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| The container also ships [mitmproxy](https://mitmproxy.org/) and the dependencies for `scripts/proxy_lp.py`, which serves your locally built `lua/output/css/main.css` and `lua/output/js/main.js` in place of the ones liquipedia.net would load. See the [wiki page](https://github.com/Liquipedia/Lua-Modules/wiki/Local-Development-Setup-for-CSS-and-JS) for the full background; inside the container the setup is: | ||
|
|
||
| 1. Start the proxy with `python scripts/proxy_lp.py` from the repository root, or via the *Launch proxy* task in `.vscode/tasks.json`. It listens on port 8080, which is forwarded to `127.0.0.1:8080` on your host. |
| # these are named volumes, which docker creates owned by root | ||
| sudo chown "$(id -u):$(id -g)" node_modules ~/.mitmproxy | ||
| npm install |
3fa3eac to
3500779
Compare
ElectricalBoy
left a comment
There was a problem hiding this comment.
mitmproxy is kept out of
requirements.txt, which covers the deploy scripts rather than optional local tooling
since python dependencies that our GHA workflows use are cached via actions/setup-python step anyway, I don't think it hurts as much to add mitmproxy to requirements.txt
|
Tested on Linux (Arch, Docker 29.7.2,
|
3500779 to
faf56d7
Compare
|
Both confirmed and fixed.
Silent no-op — worse than it looked. The reason nothing is logged is that Also moved I left adding |
faf56d7 to
6b3d883
Compare
6b3d883 to
4f8052b
Compare
4f8052b to
81649d2
Compare
Lets scripts/proxy_lp.py run inside the container, serving locally built CSS and JS into the live wiki as described on the Local Development Setup wiki page, without every contributor having to set the proxy up by hand. Port 8080 is forwarded so the browser on the host can reach it, and the mitmproxy CA lives in a volume so the certificate only has to be trusted in the browser once rather than after every rebuild. mitmproxy is deliberately kept out of requirements.txt, which covers the deploy scripts rather than optional local tooling, and pinned in the Dockerfile like the rest of the toolchain.
forwardPorts is an editor side tunnel, so a container started with the CLI never published 8080 and the README's claim that it reaches 127.0.0.1:8080 on the host only held in VS Code. Adds appPort next to it, bound to loopback rather than every interface, since the alternative leaves an open forward proxy reachable from the local network. A fresh container also had no lua/output, so the mapper raised FileNotFoundError, mitmproxy passed the request upstream and the page looked untouched. Nothing was logged: proxy_lp.py builds its own Master from default_addons(), which has no TermLog, so addon errors go nowhere. Builds in post-create.sh and says which file is missing instead of failing mutely, and moves the build to the front of the README steps rather than leaving it at the end of the edit loop. Reported by Eetwalt.
81649d2 to
5f084a7
Compare
What
Installs mitmproxy in the devcontainer and forwards port 8080, so
scripts/proxy_lp.pycan serve locally built CSS and JS into the live wiki as described on the Local Development Setup wiki page.The CA lives in a volume so the certificate only has to be trusted in the browser once, rather than after every rebuild.
Stacked on #7955 — that one should merge first.
How it was tested
In the container:
npm run build, then startedpython scripts/proxy_lp.pyand requested through it —liquipedia.net/commons/load.php?only=stylesreturnedVia: HTTP/1.1 LiquipediaMapperand matchedlua/output/css/main.cssbyte-for-byte...?only=scriptsmatchedlua/output/js/main.jsbyte-for-byte~/.mitmproxy/mitmproxy-ca-cert.pemgenerated in the volumenpm run lua-teststill 761 successes / 0 failuresNot tested: the host-side port forward, which is a VS Code Dev Containers feature the CLI does not set up the same way. The proxy was verified from inside the container only.