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+
124FROM 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
1843ENV 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" ]
0 commit comments