Skip to content

docker: include Node 22 so the image can lint npx servers - #177

Open
abu-tahir-0 wants to merge 2 commits into
patsypppe:mainfrom
abu-tahir-0:feat/docker-node
Open

abu-tahir-0 wants to merge 2 commits into
patsypppe:mainfrom
abu-tahir-0:feat/docker-node

Conversation

@abu-tahir-0

Copy link
Copy Markdown

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

  • New node:22-slim stage; the final image copies the node binary and /usr/local/lib/node_modules.
  • npm and npx are recreated as symlinks into node_modules. COPY --from flattens the originals into scripts whose relative require('../lib/cli.js') then resolves against /usr/local/bin, which failed with MODULE_NOT_FOUND in testing.
  • HOME=/tmp for the unprivileged user: npm/npx keep their cache under $HOME, the user has no home, and /work is not writable by it.
  • tests/harness/test_distribution.py asserts the stage, the module copy, both CLI entry points and HOME=/tmp.

Stacked on #176, which fixes the image build itself (fixtures/server was 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.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker: include Node so the image can lint npx servers

1 participant