-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (40 loc) · 1.64 KB
/
Copy pathDockerfile
File metadata and controls
43 lines (40 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Run pnpm non-interactively: without a TTY, pnpm 10 otherwise aborts when it
# needs to purge node_modules (ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY).
ENV CI=true
RUN corepack enable
COPY . /app
WORKDIR /app
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
# Run the build on the NATIVE builder platform (--platform=$BUILDPLATFORM), not
# the target platform. tsup/esbuild ship a Go binary that crashes under QEMU
# emulation (fatal error: lfstack.push) when cross-building. The output is plain,
# architecture-independent JavaScript, so it is safe to copy into a target-arch
# final image below.
FROM --platform=$BUILDPLATFORM node:20-slim AS build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV CI=true
RUN corepack enable
COPY . /app
WORKDIR /app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 3000
# No MCP_BIND_ADDRESS here on purpose. The image keeps the loopback default, which
# a sidecar or any other container sharing this network namespace can reach.
# Publishing a port is the case that needs a wider bind, and that stays an explicit
# `-e MCP_BIND_ADDRESS=0.0.0.0` alongside an inbound credential. See "Network
# Exposure" in the README.
#
# Split so that overriding the command only replaces the arguments, not the
# interpreter: `docker run <image> http --stateless` works as written.
ENTRYPOINT [ "node", "dist/index.js" ]
CMD [ "http" ]
USER 1000