Repository navigation
docker: include Node 22 so the image can lint npx servers - #177
Open
abu-tahir-0 wants to merge 2 commits into
Open
abu-tahir-0 wants to merge 2 commits into
abu-tahir-0 wants to merge 2 commits into
Conversation
harness/pyproject.toml force-includes ../fixtures/server, but the build stage copied only harness/ and the ignore file excluded fixtures/ entirely, so `python -m build` failed with "Forced include not found" and the image could not be built. Copy that one fixture package and let the ignore file through it. Verified with a local build and `version`.
The image had no Node, so `lint --command "npx -y ..."` could not run inside it. Copy Node from the official slim image, link npm and npx into node_modules (COPY flattens the symlinks), and give the unprivileged user HOME=/tmp for the npx cache.
This branch has not been deployed
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.
Problem
The image carried only Python, so
docker run ... lint --command "npx -y ..."could not work; the most common way to start an MCP server was unavailable inside the scanner's own container. Closes #150.Solution
node:22-slimstage; the final image copies thenodebinary and/usr/local/lib/node_modules.npmandnpxare recreated as symlinks intonode_modules.COPY --fromflattens the originals into scripts whose relativerequire('../lib/cli.js')then resolves against/usr/local/bin, which failed withMODULE_NOT_FOUNDin testing.HOME=/tmpfor the unprivileged user: npm/npx keep their cache under$HOME, the user has no home, and/workis not writable by it.tests/harness/test_distribution.pyasserts the stage, the module copy, both CLI entry points andHOME=/tmp.Stacked on #176, which fixes the image build itself (
fixtures/serverwas missing from the build context). The first commit belongs to that PR; rebase after it merges.Testing
docker build -t toolgauge-node-test .— succeeds.docker run --rm --entrypoint sh toolgauge-node-test -c 'node --version && npm --version && npx --version && echo HOME=$HOME && id -u'—v22.23.5,10.9.9,10.9.9,HOME=/tmp,10001.docker run --rm toolgauge-node-test lint --command "npx -y @modelcontextprotocol/server-memory" --format json— downloaded the server through npx inside the image and produced the lint report (exit 1 on its findings), which is the use case this issue describes.pytest tests/harness/test_distribution.py— 13 passed.Impact
The container can lint the Node/TypeScript servers that make up most of the ecosystem, without the operator installing Node.