review: harden the Docker image + align GHCR action versions
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
This commit is contained in:
parent
941bf13587
commit
f5e095e8f0
3 changed files with 29 additions and 4 deletions
|
|
@ -18,6 +18,12 @@ test-servers/build
|
||||||
storybook-static
|
storybook-static
|
||||||
coverage
|
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)
|
# Packed tarballs (the image makes its own)
|
||||||
*.tgz
|
*.tgz
|
||||||
|
|
||||||
|
|
|
||||||
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
|
|
@ -166,7 +166,7 @@ jobs:
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|
@ -174,15 +174,23 @@ jobs:
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/${{ github.repository }}
|
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
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: push
|
id: push
|
||||||
|
|
@ -195,7 +203,7 @@ jobs:
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
- name: Generate artifact attestation
|
- name: Generate artifact attestation
|
||||||
uses: actions/attest-build-provenance@v3
|
uses: actions/attest-build-provenance@v4
|
||||||
with:
|
with:
|
||||||
subject-name: ghcr.io/${{ github.repository }}
|
subject-name: ghcr.io/${{ github.repository }}
|
||||||
subject-digest: ${{ steps.push.outputs.digest }}
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
|
|
||||||
11
Dockerfile
11
Dockerfile
|
|
@ -31,6 +31,17 @@ ENV HOST=0.0.0.0 \
|
||||||
MCP_AUTO_OPEN_ENABLED=false
|
MCP_AUTO_OPEN_ENABLED=false
|
||||||
EXPOSE 6274
|
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.
|
# Default to the web UI; override the args to run --cli / --tui.
|
||||||
ENTRYPOINT ["mcp-inspector"]
|
ENTRYPOINT ["mcp-inspector"]
|
||||||
CMD ["--web"]
|
CMD ["--web"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue