Skip to content

Commit 5b92fcc

Browse files
cliffhallclaude
andcommitted
chore(docker): build filesystem, memory and sequentialthinking from the workspace lockfile
Each image now installs with `npm ci --workspace src/<server>` from the root package.json and package-lock.json, so the root lockfile and its `overrides` reach the image instead of a lockfile-less `npm install`. The release stage uses `--omit=dev` (`--omit-dev` is not an npm flag). Each Dockerfile gets a `Dockerfile.dockerignore` allow-list for the repository-root context, the shape src/everything/Dockerfile set (#3309). sequentialthinking keeps no state and now runs as the `node` user. filesystem and memory stay root for now: their bind mounts and volumes are written by the server, so the switch is decided in #4741. memory keeps /app (a symlink to the workspace directory), so the documented `claude-memory:/app/dist` volume still holds the graph. Closes #5345 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 281b167 commit 5b92fcc

6 files changed

Lines changed: 171 additions & 35 deletions

File tree

‎src/filesystem/Dockerfile‎

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,53 @@
1+
# The `filesystem` server's container image (#5345). Build it from the
2+
# repository root, which is the build context:
3+
#
4+
# docker build -f src/filesystem/Dockerfile -t mcp/filesystem .
5+
#
6+
# `filesystem` is an npm workspace, so its lockfile and the `overrides` that
7+
# pin its transitive dependencies live in the root package.json and
8+
# package-lock.json, not in src/filesystem. Both stages install from them with
9+
# `npm ci`, so the image gets exactly the versions this repository tested,
10+
# rather than whatever a lockfile-less `npm install` resolves on the day.
11+
# Dockerfile.dockerignore (next to this file) keeps the context to what the
12+
# build reads. The shape is src/everything/Dockerfile's (#3309).
13+
#
14+
# Unlike that image, this one still runs as root. The server reads and writes
15+
# the host directories bind-mounted under /projects, and a non-root user can
16+
# only write to them when the host owner's uid matches, so the switch changes
17+
# what existing setups can do. It is decided with the other images in #4741.
18+
119
FROM node:24-alpine AS builder
220

3-
WORKDIR /app
21+
WORKDIR /repo
422

5-
COPY src/filesystem /app
6-
COPY tsconfig.json /tsconfig.json
23+
# Manifests first, so the dependency layer is reused until one of them changes.
24+
COPY package.json package-lock.json .npmrc tsconfig.json ./
25+
COPY src/filesystem/package.json src/filesystem/
726

8-
RUN --mount=type=cache,target=/root/.npm npm install
27+
# `--ignore-scripts` skips the workspace's `prepare` build, which needs the
28+
# source; the build runs explicitly below.
29+
RUN --mount=type=cache,target=/root/.npm \
30+
npm ci --workspace src/filesystem --ignore-scripts
931

10-
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
32+
COPY src/filesystem src/filesystem
33+
RUN npm run build --workspace src/filesystem
1134

1235

1336
FROM node:24-alpine AS release
1437

15-
WORKDIR /app
38+
ENV NODE_ENV=production
1639

17-
COPY --from=builder /app/dist /app/dist
18-
COPY --from=builder /app/package.json /app/package.json
19-
COPY --from=builder /app/package-lock.json /app/package-lock.json
40+
WORKDIR /repo
2041

21-
ENV NODE_ENV=production
42+
COPY package.json package-lock.json .npmrc ./
43+
COPY src/filesystem/package.json src/filesystem/
44+
45+
RUN --mount=type=cache,target=/root/.npm \
46+
npm ci --workspace src/filesystem --omit=dev --ignore-scripts
47+
48+
COPY --from=builder /repo/src/filesystem/dist src/filesystem/dist
2249

23-
RUN npm ci --ignore-scripts --omit-dev
50+
WORKDIR /repo/src/filesystem
2451

25-
ENTRYPOINT ["node", "/app/dist/index.js"]
52+
# The allowed directories are the run arguments (`/projects` in the README).
53+
ENTRYPOINT ["node", "dist/index.js"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The build context for src/filesystem/Dockerfile (#5345). BuildKit reads a
2+
# `<Dockerfile>.dockerignore` beside the Dockerfile in place of a root
3+
# .dockerignore, so this allow-list applies to this image only. The context is
4+
# the repository root, so start from nothing and admit only what the build
5+
# copies: the root manifests and lockfile, and the server's source without
6+
# its build output or test artifacts.
7+
*
8+
!package.json
9+
!package-lock.json
10+
!.npmrc
11+
!tsconfig.json
12+
!src/filesystem
13+
src/filesystem/node_modules
14+
src/filesystem/dist
15+
src/filesystem/coverage

‎src/memory/Dockerfile‎

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,59 @@
1+
# The `memory` server's container image (#5345). Build it from the repository
2+
# root, which is the build context:
3+
#
4+
# docker build -f src/memory/Dockerfile -t mcp/memory .
5+
#
6+
# `memory` is an npm workspace, so its lockfile and the `overrides` that pin
7+
# its transitive dependencies live in the root package.json and
8+
# package-lock.json, not in src/memory. Both stages install from them with
9+
# `npm ci`, so the image gets exactly the versions this repository tested,
10+
# rather than whatever a lockfile-less `npm install` resolves on the day.
11+
# Dockerfile.dockerignore (next to this file) keeps the context to what the
12+
# build reads. The shape is src/everything/Dockerfile's (#3309).
13+
#
14+
# Two things differ from that image, both to keep existing setups working:
15+
#
16+
# - The server stays reachable at /app. The README stores the graph in a named
17+
# volume mounted over /app/dist, which is where the default memory file
18+
# lives (next to dist/index.js), so /app is a symlink to the workspace
19+
# directory and that mount still lands on the server's dist.
20+
# - It still runs as root. A volume an earlier image created holds a graph
21+
# owned by root, which a non-root server could read but not save. The switch
22+
# is decided with the other images in #4741.
23+
124
FROM node:24-alpine AS builder
225

3-
COPY src/memory /app
4-
COPY tsconfig.json /tsconfig.json
26+
WORKDIR /repo
527

6-
WORKDIR /app
28+
# Manifests first, so the dependency layer is reused until one of them changes.
29+
COPY package.json package-lock.json .npmrc tsconfig.json ./
30+
COPY src/memory/package.json src/memory/
731

8-
RUN --mount=type=cache,target=/root/.npm npm install
32+
# `--ignore-scripts` skips the workspace's `prepare` build, which needs the
33+
# source; the build runs explicitly below.
34+
RUN --mount=type=cache,target=/root/.npm \
35+
npm ci --workspace src/memory --ignore-scripts
936

10-
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
37+
COPY src/memory src/memory
38+
RUN npm run build --workspace src/memory
1139

12-
FROM node:24-alpine AS release
1340

14-
COPY --from=builder /app/dist /app/dist
15-
COPY --from=builder /app/package.json /app/package.json
16-
COPY --from=builder /app/package-lock.json /app/package-lock.json
41+
FROM node:24-alpine AS release
1742

1843
ENV NODE_ENV=production
1944

20-
WORKDIR /app
45+
WORKDIR /repo
2146

22-
RUN npm ci --ignore-scripts --omit-dev
47+
COPY package.json package-lock.json .npmrc ./
48+
COPY src/memory/package.json src/memory/
49+
50+
RUN --mount=type=cache,target=/root/.npm \
51+
npm ci --workspace src/memory --omit=dev --ignore-scripts
52+
53+
COPY --from=builder /repo/src/memory/dist src/memory/dist
54+
55+
RUN ln -s /repo/src/memory /app
56+
57+
WORKDIR /app
2358

24-
ENTRYPOINT ["node", "dist/index.js"]
59+
ENTRYPOINT ["node", "dist/index.js"]

‎src/memory/Dockerfile.dockerignore‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The build context for src/memory/Dockerfile (#5345). BuildKit reads a
2+
# `<Dockerfile>.dockerignore` beside the Dockerfile in place of a root
3+
# .dockerignore, so this allow-list applies to this image only. The context is
4+
# the repository root, so start from nothing and admit only what the build
5+
# copies: the root manifests and lockfile, and the server's source without
6+
# its build output or test artifacts.
7+
*
8+
!package.json
9+
!package-lock.json
10+
!.npmrc
11+
!tsconfig.json
12+
!src/memory
13+
src/memory/node_modules
14+
src/memory/dist
15+
src/memory/coverage

‎src/sequentialthinking/Dockerfile‎

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,52 @@
1+
# The `sequentialthinking` server's container image (#5345). Build it from the
2+
# repository root, which is the build context:
3+
#
4+
# docker build -f src/sequentialthinking/Dockerfile -t mcp/sequentialthinking .
5+
#
6+
# `sequentialthinking` is an npm workspace, so its lockfile and the `overrides`
7+
# that pin its transitive dependencies live in the root package.json and
8+
# package-lock.json, not in src/sequentialthinking. Both stages install from
9+
# them with `npm ci`, so the image gets exactly the versions this repository
10+
# tested, rather than whatever a lockfile-less `npm install` resolves on the
11+
# day. Dockerfile.dockerignore (next to this file) keeps the context to what
12+
# the build reads. The shape is src/everything/Dockerfile's (#3309).
13+
#
14+
# The server keeps no state on disk, so it runs as the base image's `node`
15+
# user rather than root.
16+
117
FROM node:24-alpine AS builder
218

3-
COPY src/sequentialthinking /app
4-
COPY tsconfig.json /tsconfig.json
19+
WORKDIR /repo
520

6-
WORKDIR /app
21+
# Manifests first, so the dependency layer is reused until one of them changes.
22+
COPY package.json package-lock.json .npmrc tsconfig.json ./
23+
COPY src/sequentialthinking/package.json src/sequentialthinking/
724

8-
RUN --mount=type=cache,target=/root/.npm npm install
25+
# `--ignore-scripts` skips the workspace's `prepare` build, which needs the
26+
# source; the build runs explicitly below.
27+
RUN --mount=type=cache,target=/root/.npm \
28+
npm ci --workspace src/sequentialthinking --ignore-scripts
929

10-
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
30+
COPY src/sequentialthinking src/sequentialthinking
31+
RUN npm run build --workspace src/sequentialthinking
1132

12-
FROM node:24-alpine AS release
1333

14-
COPY --from=builder /app/dist /app/dist
15-
COPY --from=builder /app/package.json /app/package.json
16-
COPY --from=builder /app/package-lock.json /app/package-lock.json
34+
FROM node:24-alpine AS release
1735

1836
ENV NODE_ENV=production
1937

20-
WORKDIR /app
38+
WORKDIR /repo
39+
40+
COPY package.json package-lock.json .npmrc ./
41+
COPY src/sequentialthinking/package.json src/sequentialthinking/
42+
43+
RUN --mount=type=cache,target=/root/.npm \
44+
npm ci --workspace src/sequentialthinking --omit=dev --ignore-scripts
45+
46+
COPY --from=builder /repo/src/sequentialthinking/dist src/sequentialthinking/dist
47+
48+
WORKDIR /repo/src/sequentialthinking
2149

22-
RUN npm ci --ignore-scripts --omit-dev
50+
USER node
2351

2452
ENTRYPOINT ["node", "dist/index.js"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The build context for src/sequentialthinking/Dockerfile (#5345). BuildKit reads a
2+
# `<Dockerfile>.dockerignore` beside the Dockerfile in place of a root
3+
# .dockerignore, so this allow-list applies to this image only. The context is
4+
# the repository root, so start from nothing and admit only what the build
5+
# copies: the root manifests and lockfile, and the server's source without
6+
# its build output or test artifacts.
7+
*
8+
!package.json
9+
!package-lock.json
10+
!.npmrc
11+
!tsconfig.json
12+
!src/sequentialthinking
13+
src/sequentialthinking/node_modules
14+
src/sequentialthinking/dist
15+
src/sequentialthinking/coverage

0 commit comments

Comments
 (0)