ci(docker): add v2 Dockerfile + GHCR publish job (#1646)
v1 published a container image but v2 arrived with no Dockerfile (the client/server/cli layout is gone). Add a v2 image for the single-package / launcher architecture and wire the release-gated GHCR publish job. - `Dockerfile`: two-stage build — stage 1 installs + `npm pack`s the publishable tarball; stage 2 `npm install -g`s that tarball, so the image ships the exact same artifact as npm with a clean `mcp-inspector` bin. Defaults to `--web` on `0.0.0.0:6274`, browser auto-open off. `.dockerignore` keeps the context lean and forces a clean in-container install/build. - `publish-github-container-registry` job in main.yml (ported from v1): release-gated, multi-arch (amd64/arm64) build+push to GHCR with a provenance attestation. Independent of the npm `publish` job. - README: document the image + how to run it; the release section now covers both publish jobs. Verified locally: `docker build` succeeds, the container serves `/` (HTTP 200 with the injected token) and dispatches `--cli` / `--tui`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
This commit is contained in:
parent
483981064a
commit
941bf13587
4 changed files with 140 additions and 2 deletions
32
.dockerignore
Normal file
32
.dockerignore
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Keep the build context small and force a clean, in-container install/build.
|
||||||
|
# Host node_modules and build outputs are excluded so nothing stale or
|
||||||
|
# wrong-architecture is copied in — the builder stage runs its own
|
||||||
|
# `npm install && npm pack`.
|
||||||
|
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
|
||||||
|
# Installed deps (root + every client) — reinstalled in the image
|
||||||
|
node_modules
|
||||||
|
clients/*/node_modules
|
||||||
|
test-servers/node_modules
|
||||||
|
|
||||||
|
# Build outputs — rebuilt in the image
|
||||||
|
clients/*/build
|
||||||
|
clients/web/dist
|
||||||
|
test-servers/build
|
||||||
|
storybook-static
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# Packed tarballs (the image makes its own)
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Local / editor / env
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
.DS_Store
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
.claude
|
||||||
|
.playwright-mcp
|
||||||
|
*.log
|
||||||
54
.github/workflows/main.yml
vendored
54
.github/workflows/main.yml
vendored
|
|
@ -146,3 +146,57 @@ jobs:
|
||||||
run: npm publish --access public --provenance
|
run: npm publish --access public --provenance
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
# Build and push the multi-arch container image to GHCR on a published
|
||||||
|
# release. The image installs the packed tarball (`Dockerfile`) so it ships
|
||||||
|
# the same artifact as npm. Independent of the npm `publish` job (both gated on
|
||||||
|
# the release event) — a container failure doesn't block the npm publish.
|
||||||
|
publish-github-container-registry:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
environment: release
|
||||||
|
needs: build
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v3
|
||||||
|
with:
|
||||||
|
subject-name: ghcr.io/${{ github.repository }}
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
|
|
|
||||||
36
Dockerfile
Normal file
36
Dockerfile
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Build stage — install everything, build all clients, and pack the exact
|
||||||
|
# tarball npm would publish. `npm install` runs the root postinstall cascade
|
||||||
|
# (per-client installs, since v2 is not a workspace); `npm pack` runs `prepack`
|
||||||
|
# (`npm run build`) and emits `modelcontextprotocol-inspector-<version>.tgz`.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
FROM node:22-slim AS builder
|
||||||
|
WORKDIR /build
|
||||||
|
COPY . .
|
||||||
|
RUN npm install && npm pack
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Runtime stage — install just the packed tarball (production deps only),
|
||||||
|
# yielding a clean global `mcp-inspector` bin: the same artifact a user gets
|
||||||
|
# from `npm i -g @modelcontextprotocol/inspector`. The package's postinstall
|
||||||
|
# early-exits under node_modules, and the tarball ships only each client's
|
||||||
|
# build/ output, so there is nothing to build here.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
FROM node:22-slim AS runner
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
COPY --from=builder /build/modelcontextprotocol-inspector-*.tgz /tmp/inspector.tgz
|
||||||
|
RUN npm install -g /tmp/inspector.tgz && rm /tmp/inspector.tgz
|
||||||
|
|
||||||
|
# Serve on all interfaces so the UI is reachable from outside the container, and
|
||||||
|
# never try to open a browser from inside it.
|
||||||
|
ENV HOST=0.0.0.0 \
|
||||||
|
CLIENT_PORT=6274 \
|
||||||
|
MCP_AUTO_OPEN_ENABLED=false
|
||||||
|
EXPOSE 6274
|
||||||
|
|
||||||
|
# Default to the web UI; override the args to run --cli / --tui.
|
||||||
|
ENTRYPOINT ["mcp-inspector"]
|
||||||
|
CMD ["--web"]
|
||||||
20
README.md
20
README.md
|
|
@ -150,7 +150,10 @@ The `smoke:*` scripts run against the in-repo build tree, which is **not** the p
|
||||||
|
|
||||||
### Cutting a release
|
### Cutting a release
|
||||||
|
|
||||||
Publishing is automated by the `publish` job in [`.github/workflows/main.yml`](.github/workflows/main.yml), gated on a **published GitHub release** (`github.event_name == 'release'`). On release it runs `npm run pack:verify` as the pre-publish gate, then `npm publish --access public --provenance` — a single `npm publish` (v2 is not an npm workspace, so there is no v1-style `publish-all`/`--workspaces`), with a signed provenance attestation via GitHub OIDC (`id-token: write`, `environment: release`, `NPM_TOKEN`).
|
Publishing is automated by two release-gated jobs in [`.github/workflows/main.yml`](.github/workflows/main.yml) (`github.event_name == 'release'`, both `needs: build`):
|
||||||
|
|
||||||
|
- **`publish`** — the npm package. Runs `npm run pack:verify` as the pre-publish gate, asserts the release tag matches the root `package.json` version, then `npm publish --access public --provenance` — a single `npm publish` (v2 is not an npm workspace, so there is no v1-style `publish-all`/`--workspaces`), with a signed provenance attestation via GitHub OIDC (`id-token: write`, `environment: release`, `NPM_TOKEN`).
|
||||||
|
- **`publish-github-container-registry`** — the container image (see [Docker](#docker)).
|
||||||
|
|
||||||
Because there is **one version number** (only the root `package.json` has one — the clients carry none, so there is nothing to keep in sync and no `check-version` step), the release flow is just:
|
Because there is **one version number** (only the root `package.json` has one — the clients carry none, so there is nothing to keep in sync and no `check-version` step), the release flow is just:
|
||||||
|
|
||||||
|
|
@ -162,7 +165,20 @@ git push --follow-tags
|
||||||
|
|
||||||
The release's target commit selects which workflow runs, so this only publishes when a release is cut from a commit carrying this (v2) workflow.
|
The release's target commit selects which workflow runs, so this only publishes when a release is cut from a commit carrying this (v2) workflow.
|
||||||
|
|
||||||
> **Docker / GHCR is not wired up yet.** v1 published a container image to GHCR, but v2 has no Dockerfile (its `client/server/cli` layout is gone). A v2 image + GHCR job is tracked separately in [#1646](https://github.com/modelcontextprotocol/inspector/issues/1646).
|
### Docker
|
||||||
|
|
||||||
|
A container image is published to GHCR (`ghcr.io/modelcontextprotocol/inspector`, `linux/amd64` + `linux/arm64`) by the release workflow. The [`Dockerfile`](Dockerfile) is a two-stage build: the first stage installs and `npm pack`s the publishable tarball; the second stage `npm install -g`s that tarball, so the image ships the exact same artifact as npm, with a clean `mcp-inspector` bin.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# run the web UI (reads the auth token from the container logs)
|
||||||
|
docker run --rm -p 6274:6274 ghcr.io/modelcontextprotocol/inspector
|
||||||
|
|
||||||
|
# or build the image locally
|
||||||
|
docker build -t mcp-inspector .
|
||||||
|
docker run --rm -p 6274:6274 mcp-inspector
|
||||||
|
```
|
||||||
|
|
||||||
|
The image defaults to `--web` bound to `0.0.0.0:6274` with browser auto-open disabled; override the args to run another mode (`docker run --rm ghcr.io/modelcontextprotocol/inspector --cli …`). Pass `-e MCP_INSPECTOR_API_TOKEN=…` to set a known token (otherwise one is generated and printed in the logs), or `-e DANGEROUSLY_OMIT_AUTH=true` to disable auth.
|
||||||
|
|
||||||
## Contributing — `AGENTS.md` and `CLAUDE.md`
|
## Contributing — `AGENTS.md` and `CLAUDE.md`
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue