Skip to content

feat: Add mitmproxy to the devcontainer - #7956

Open
Rathoz wants to merge 2 commits into
mainfrom
feat/devcontainer-mitmproxy
Open

feat: Add mitmproxy to the devcontainer#7956
Rathoz wants to merge 2 commits into
mainfrom
feat/devcontainer-mitmproxy

Conversation

@Rathoz

@Rathoz Rathoz commented Aug 14, 2026

Copy link
Copy Markdown
Member

What

Installs mitmproxy in the devcontainer and forwards port 8080, so scripts/proxy_lp.py can 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 started python scripts/proxy_lp.py and requested through it —

  • liquipedia.net/commons/load.php?only=styles returned Via: HTTP/1.1 LiquipediaMapper and matched lua/output/css/main.css byte-for-byte
  • ...?only=scripts matched lua/output/js/main.js byte-for-byte
  • ~/.mitmproxy/mitmproxy-ca-cert.pem generated in the volume
  • npm run lua-test still 761 successes / 0 failures

Not 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.

@Rathoz
Rathoz requested review from a team as code owners August 14, 2026 13:10
@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from 486ec7c to 3fa3eac Compare August 17, 2026 08:38
Copilot AI lite review requested due to automatic review settings August 17, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mitmproxy version 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.

Comment thread README.md Outdated

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.
Comment on lines +7 to 9
# these are named volumes, which docker creates owned by root
sudo chown "$(id -u):$(id -g)" node_modules ~/.mitmproxy
npm install
@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from 3fa3eac to 3500779 Compare August 17, 2026 09:57
@ElectricalBoy ElectricalBoy added the qol Developer quality-of-life changes that are not deployed to wiki label Aug 17, 2026

@ElectricalBoy ElectricalBoy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Eetwalt

Eetwalt commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Tested on Linux (Arch, Docker 29.7.2, devcontainer CLI 0.87.0, no VS Code). Two issues.

forwardPorts doesn't publish the port outside VS Code

It's an editor-side tunnel, not a container property, so plain devcontainer up never passes -p and the container ends up with PortBindings: {}. With the proxy running, 127.0.0.1:8080 on the host is refused while the container IP on 8080 answers, so the README's "forwarded to 127.0.0.1:8080 on your host" only holds in VS Code.

Adding appPort next to forwardPorts fixes it (verified: docker port shows 8080/tcp -> 127.0.0.1:8080, and mitm.it plus intercepted HTTPS then work from a host browser):

"appPort": [
	"127.0.0.1:8080:8080"
],

Worth spelling out the loopback bind rather than the bare "appPort": [8080], which publishes on all interfaces and would leave an open forward proxy reachable from the local network.

Without a build, the proxy silently does nothing

post-create.sh never builds, so on a fresh container lua/output/css/main.css doesn't exist and LiquipediaMapper passes the request through to the real server with no Via header and no log line. Following README steps 1 to 3 you set up the proxy, trust the cert, load a page, see nothing change, and get no diagnostics, since npm run build only appears at step 4 as part of the edit-refresh loop.

Adding npm run build to post-create.sh is the cheap fix; logging the missing file in the addon is the sturdier one. Existing proxy_lp.py behaviour rather than something this PR introduces, but this PR is what puts it in front of people who've never built the repo.

@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from 3500779 to faf56d7 Compare August 19, 2026 13:02
@Rathoz

Rathoz commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

Both confirmed and fixed.

appPort — verified: docker port now reports 8080/tcp -> 127.0.0.1:8080 and a request from the host reaches the proxy. Took your explicit loopback form for the reason you gave. This was the one thing I called out as untested when opening the PR, so thanks for closing it properly. One tradeoff worth noting for reviewers: appPort hard-binds the host port at creation, so if something else already holds 8080 the container will not start, where VS Code would have quietly picked another port. For a proxy that needs a predictable port that seems the right trade.

Silent no-op — worse than it looked. The reason nothing is logged is that proxy_lp.py builds its own Master from default_addons(), which contains no TermLog, so every addon error goes nowhere, not just this one. Fixed both halves you suggested: post-create.sh now builds, and the mapper reports which file is missing instead of failing mutely:

LiquipediaMapper: [Errno 2] No such file or directory: 'lua/output/css/main.css'. Run npm run build first.

Also moved npm run build to step 1 in the README rather than leaving it at the end of the edit loop. Happy path re-verified: CSS and JS still served byte-for-byte with the Via header.

I left adding TermLog out of this PR, since it changes output for existing proxy users beyond what was reported, but it is a one-liner and probably worth doing separately — as it stands any future error in that addon is invisible.

@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from faf56d7 to 6b3d883 Compare August 20, 2026 08:01
@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from 6b3d883 to 4f8052b Compare August 20, 2026 08:28
Base automatically changed from feat/devcontainer to main August 21, 2026 06:37
@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from 4f8052b to 81649d2 Compare August 21, 2026 06:37
Rathoz added 2 commits August 21, 2026 13:54
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.
@Rathoz
Rathoz force-pushed the feat/devcontainer-mitmproxy branch from 81649d2 to 5f084a7 Compare August 21, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qol Developer quality-of-life changes that are not deployed to wiki

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants