devcontainer: run the NEAR git-storage sandbox as a process inside the container#138
Open
petersalomonsen wants to merge 1 commit into
Open
devcontainer: run the NEAR git-storage sandbox as a process inside the container#138petersalomonsen wants to merge 1 commit into
petersalomonsen wants to merge 1 commit into
Conversation
Reproducing CI's Playwright e2e flow locally previously meant starting
the sandbox as a sibling `docker run` from outside the dev environment.
Works on Linux hosts but breaks on macOS — Docker Desktop / colima route
container networking through a VM, so `--network host` doesn't share
the host's localhost:3030 and the workaround (shared bridge network +
named alias) requires rewriting helpers that hard-code localhost:3030.
Sidestep all of it by running the sandbox as a regular process inside
the devcontainer. The trick: a multi-stage Dockerfile that
`COPY --from=ghcr.io/petersalomonsen/near-git-storage/sandbox:main`s the
artifacts (near-sandbox binary, git-server wrapper, the compiled wasm
contracts, the pre-populated .near state) into the dev image at build
time. No docker access needed at runtime — important for GitHub
Codespaces, where docker-outside-of-docker isn't available.
A `near-git-sandbox` launcher on PATH chdirs into /opt/near-sandbox so
git-server finds its res/*.wasm, defaults the listen address to the
port the e2e helpers expect, and the rest is just node side:
post-create.sh:
- pulseaudio (Web Audio sink; without it the audio-worklet code
never starts and the broadcast / audio-comparison specs hang)
- yarn install + playwright install chromium in wasmaudioworklet/
- npm install in tools/faust2as (Faust → AS source generator used
by faust2as-compilation.spec.js) and tools/claude-bridge (relay
spawned by claude-bridge.spec.js)
.devcontainer/README.md walks through the design and captures the
macOS-docker-networking + Playwright-image-version pitfalls for the
next agent reproducing the e2e flow from a different angle.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5c8491d to
f9903f9
Compare
Deploying webassemblymusic with
|
| Latest commit: |
f9903f9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://29e8be01.webassemblymusic.pages.dev |
| Branch Preview URL: | https://devcontainer-sandbox-in-proc.webassemblymusic.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reproducing CI's Playwright e2e flow locally previously meant starting the sandbox as a sibling
docker runfrom outside the dev environment. Fine on Linux hosts but broken on macOS — Docker Desktop / colima route container networking through a VM, so--network hostdoesn't share the host'slocalhost:3030and the workaround (shared bridge network + named alias) requires rewriting helpers that hard-codelocalhost:3030.This PR makes the devcontainer self-sufficient: the sandbox runs as a regular process inside the container, the e2e suite talks to it over
localhost, and there's no docker access needed at runtime. That last bit is important for GitHub Codespaces, wheredocker-outside-of-dockerisn't available.How
.devcontainer/Dockerfile(new) is a multi-stage build:FROM ghcr.io/petersalomonsen/near-git-storage/sandbox:main AS sandbox— pulled purely toCOPY --from=….FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04— the actual base. Installspulseaudio, copies the sandbox'sgit-serverbinary,/app(which containsres/*.wasm), and/root/.near(the prepopulated sandbox state) in via multi-stage COPY.near-git-sandboxlauncher on PATH that chdirs into/opt/near-sandboxand runsgit-serveronlocalhost:3030.The
COPY --from=happens at image build time, so neither the running devcontainer nor Codespaces need access to docker..devcontainer/devcontainer.jsonpoints at the Dockerfile via"build": { "dockerfile": "Dockerfile" }..devcontainer/post-create.shis now just the node side:pulseaudio -D,yarn install+yarn playwright install chromium, andnpm installintools/faust2as/+tools/claude-bridge/..devcontainer/README.mdwalks through the design and documents the macOS-docker-networking + Playwright-image-version pitfalls for the next agent reproducing the e2e flow.Test plan
Follow-ups (out of scope here)
test.skip(!!process.env.CI)onbroadcast-signal > hot-save. It passes in the dev container, so the issue is narrower than "anything CI". Could be re-scoped toGITHUB_ACTIONSonly.tools/faust2as/faust2as.js(mirror PR faust transpiler: recognise StaticArray<T> SIG-class fields #134's ASC-backend fix). That'd unskipfaust2as-compilation.spec.js > clarinet.🤖 Generated with Claude Code