Files
magpie/Dockerfile
T
yetone 69233d6bcf docker: the image has npx, node, npm, uvx and python for the Library's MCP servers
Passings_z on X: in magpie's Docker image, adding Chrome DevTools' MCP
server from the Library said "npx not found". The runtime stage is
debian:12-slim with ca-certificates and curl only, and the Library's
servers run in the container (gateway mode keeps Library's MCP servers
and the router), so every featured entry but the remote ones failed the
same way: npx for chrome-devtools, playwright, filesystem, memory,
sequential-thinking, brave, firecrawl, tavily and everme, uvx for fetch,
git and time, and the registry's npx/uvx entries.

The image now copies in Node 24.22.3 (node, npm, npx, from the official
bookworm image, matching Debian 12's glibc) and uv 0.13.7 (uv, uvx, from
astral's image). python and python3 are a two-line shim onto uv's own
Python, which uv downloads into the volume on first use (UV_PYTHON=3.14).
UV_PYTHON_PREFERENCE=only-managed keeps uv from taking the shim as an
interpreter: without it uvx recursed and hung looking for one.

Size (docker image inspect / du -sxm / as root):
  origin/main  74,636,782 B compressed, 190 MB on disk
  this         142,667,379 B compressed, 370 MB on disk  (+68 MB, +180 MB)
node is 127 MB of it, npm 19 MB, uv and uvx 43 MB. Bun in place of npx
was weighed and left: agents in the container read PATH themselves, and
Bun's Node compatibility isn't every server's.

The image still has no browser (Chrome would be ~300 MB more for every
user). Chrome DevTools' and Playwright's servers start, list their tools,
and every tool then fails: "Could not find Google Chrome executable for
channel 'stable' at: /opt/google/chrome/chrome" (seen in the image). The
check now reports such a server, run by npx/bunx/pnpx in a container with
no /opt/google/chrome/chrome and no option pointing it at a browser
(--browserUrl/-u, --wsEndpoint, --executablePath, --channel,
--autoConnect; --cdp-endpoint, --executable-path, --browser,
--extension), as Why "nobrowser" with its tools still counted. The row
says "no Chrome here", and its tooltip points at Magpie Browser or the
server's option for a Chrome it can reach; the hub's text says the same.
Desktops, macOS and an image with Chrome are unchanged. A docker-launched
(OCI) entry still says docker not found: there is no Docker in the
container. Docs (en, zh, ja docker.html) get an "MCP servers" section;
the Docker workflow's smoke test runs node/npm/npx/uvx/uv -v and finds
python3 and python.

Run:
- Docker on xiaomi-gpu, origin/main's Dockerfile vs this one, web mode
  with a fresh volume, servers added with `magpie library mcp add` and
  checked through POST /api/library/mcp/check:
  - origin/main: chrome-devtools, memory: notfound "npx"; fetch:
    notfound "uvx" (the report).
  - this: memory ok, 9 tools; fetch (uvx mcp-server-fetch) ok, 1 tool,
    Python downloaded on first run; chrome-devtools error nobrowser
    --browserUrl, 33 tools.
  - tools/call over stdio inside the container with a small node MCP
    client: memory create_entities returned the entity; fetch fetched
    https://example.com; chrome-devtools new_page returned the Chrome
    error above.
- go test -run 'TestNoBrowser|TestCheckSaysNoBrowser|TestCheckStdio'
  ./internal/library on mote: ok. Broken by hand (the hook in
  checkServer turned off): TestCheckSaysNoBrowser red, "got {State:ok
  Tools:3 …}".
- GUI on mote, Chromium and WebKit, en zh zh-TW ja de, 1100 and 390:
  mcp-no-browser (new), mcp-home-health, library-mcp-health, i18n-keys,
  i18n-en-no-cjk: 58 of 58 pass.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and go build ok on mote.
- go test -timeout 45m ./... on mote at this head (on e1c186cfe): 103
  packages ok, none failed (internal/gateway 1039s, internal/library
  408s).

Not tried: an arm64 build of the image (both base images are
multi-arch; CI builds it). The test box's network to npm dropped
mid-run: npx -y then timed out the 30s check step, and one npx install
cut short left ~/.npm/_npx with a missing module until it was removed;
that is npm's cache, the same on a desktop.
2026-11-18 10:02:53 +08:00

84 lines
3.3 KiB
Docker

FROM golang:1.26-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
COPY third_party ./third_party
RUN go mod download
COPY . .
ARG VERSION=dev
RUN CGO_ENABLED=0 go build -tags nogui -trimpath \
-ldflags "-s -w -X main.version=${VERSION}" -o /out/magpie . \
&& mkdir -p /config/home /config/cache /config/data /config/state
# The runtimes the Library's MCP servers start with: npx (most of them,
# chrome-devtools among them: "npx not found", Passings_z on X), node and
# npm (magpie installs an npx server's package and runs it with node,
# mcp_npx.go), and uvx. Node is the official build, for Debian 12's glibc;
# uv's static binaries download the Python a uvx server needs into the
# volume the first time.
FROM node:24.22.3-bookworm-slim AS node
FROM ghcr.io/astral-sh/uv:0.13.7 AS uv
# Debian, not distroless: a subscription's CLI is installed with its
# vendor's `curl … | bash` (Cursor, Devin, Grok Build), and the CLI it
# installs is a glibc binary that needs a full system's loader and
# libraries. distroless with a copied curl ran the installer, but Cursor's
# cursor-agent then failed with "cannot execute: required file not found".
# Debian 12 has the glibc, libgcc and libstdc++ the plugins' Bun needs too,
# and bash for a NAS panel's terminal. nonroot keeps distroless's uid 65532,
# so a volume made by an older image stays writable.
FROM debian:12-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -g 65532 nonroot \
&& useradd -u 65532 -g nonroot -d /config/home -s /bin/bash nonroot
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/lib/node_modules/npm /usr/local/lib/node_modules/npm
COPY --from=uv /uv /uvx /usr/local/bin/
# python and python3 are uv's own Python, downloaded once, so a server
# started as `python3 server.py` runs too. uv takes only its own Pythons
# (UV_PYTHON_PREFERENCE below): one found on PATH would be this script,
# which asks uv again, and uvx hung looking for an interpreter.
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
&& printf '#!/bin/sh\nexec uv run --no-project --quiet python "$@"\n' > /usr/local/bin/python3 \
&& chmod 755 /usr/local/bin/python3 \
&& ln -s python3 /usr/local/bin/python
COPY --from=build /out/magpie /magpie
# magpie on PATH, so `magpie accounts add …` works in that terminal
RUN ln -s /magpie /usr/local/bin/magpie
USER nonroot
COPY --from=build --chown=65532:65532 /config /config
# Everything magpie and the sign-ins it manages write goes into the volume:
# its own files (/config/magpie), sign-ins kept where an agent keeps them
# (~/.codex, ~/.claude…, under HOME), and the cache holding Bun and the
# model catalog. magpie makes the folders a volume from an older image
# lacks.
ENV HOME=/config/home \
XDG_CONFIG_HOME=/config \
XDG_CACHE_HOME=/config/cache \
XDG_DATA_HOME=/config/data \
XDG_STATE_HOME=/config/state \
NPM_CONFIG_UPDATE_NOTIFIER=false \
UV_PYTHON_PREFERENCE=only-managed \
UV_PYTHON=3.14 \
MAGPIE_ADDR=0.0.0.0:3425
VOLUME /config
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD ["/magpie", "healthcheck"]
EXPOSE 3425 3430
ENTRYPOINT ["/magpie"]
CMD ["serve"]