From f5e095e8f0c601f0b7a74968f631c1e4e3038ff6 Mon Sep 17 00:00:00 2001 From: cliffhall Date: Sat, 11 Jul 2026 09:43:04 -0400 Subject: [PATCH] review: harden the Docker image + align GHCR action versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address PR #1648 review: - Bump the GHCR action majors to match current v1 (docker/login-action v4, docker/metadata-action v6, docker/setup-buildx-action v4, actions/attest-build-provenance v4) to avoid Dependabot churn. - Make the image tags explicit (`type=semver` + `flavor: latest=true`) instead of relying on `flavor.latest=auto`, so a release lands both the version tags and `:latest` — the README's bare `ghcr.io/…/inspector` URL won't 404. - Run the container as the non-root `node` user with /home/node as workdir (its writable home is where the inspector stores the catalog / OAuth state). - Add a HEALTHCHECK that probes `/` via Node's global fetch (no curl in slim). - Trim specification/ and docs/ from the build context. (test-servers/ stays — `tsc -b` typechecks the integration tests that import its alias, so excluding it breaks the build.) Re-verified locally: `docker build` succeeds, the container runs as uid 1000 (node), serves `/` (200), and the HEALTHCHECK reports healthy. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw --- .dockerignore | 6 ++++++ .github/workflows/main.yml | 16 ++++++++++++---- Dockerfile | 11 +++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index df1dad5e..5f7a290f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -18,6 +18,12 @@ test-servers/build storybook-static coverage +# Docs/specs aren't referenced by the build — trim them from the context. +# (test-servers/ stays: `tsc -b` typechecks the integration tests that import +# the `@modelcontextprotocol/inspector-test-server` alias.) +specification +docs + # Packed tarballs (the image makes its own) *.tgz diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2e4fbf0c..fbdd32a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -166,7 +166,7 @@ jobs: uses: actions/checkout@v6 - name: Log in to the Container registry - uses: docker/login-action@v3 + uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} @@ -174,15 +174,23 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v5 + uses: docker/metadata-action@v6 with: images: ghcr.io/${{ github.repository }} + # Be explicit rather than relying on `flavor.latest=auto`: on a release + # cut both the version tags and `latest` land, so the README's bare + # `ghcr.io/…/inspector` (implicit `:latest`) never 404s. + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + flavor: | + latest=true - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v4 - name: Build and push Docker image id: push @@ -195,7 +203,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Generate artifact attestation - uses: actions/attest-build-provenance@v3 + uses: actions/attest-build-provenance@v4 with: subject-name: ghcr.io/${{ github.repository }} subject-digest: ${{ steps.push.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 07fddb10..c41c415e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,17 @@ ENV HOST=0.0.0.0 \ MCP_AUTO_OPEN_ENABLED=false EXPOSE 6274 +# Run as the non-root `node` user the base image ships. Its home (/home/node) is +# where the inspector writes runtime state (the default catalog, OAuth token +# storage), so use it as the working directory. +USER node +WORKDIR /home/node + +# Report readiness by probing the served SPA (`/` needs no auth). Uses Node's +# global fetch — no curl/wget in the slim image. +HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \ + CMD node -e "fetch('http://127.0.0.1:'+(process.env.CLIENT_PORT||6274)+'/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" + # Default to the web UI; override the args to run --cli / --tui. ENTRYPOINT ["mcp-inspector"] CMD ["--web"]