Add esbuild production bundle and multi-stage slim Docker image.
Bundle server (and mcp entry) into a single JS file with deps inlined, minify UI into one HTML, and ship only dist/ in the runtime image.
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -1,8 +1,20 @@
|
||||
FROM node:20-alpine
|
||||
# Multi-stage: esbuild produces a single Node file (deps inlined) + minified UI.
|
||||
# Final image has no node_modules — only dist/ + runtime Node.
|
||||
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev
|
||||
RUN npm ci
|
||||
COPY src/ ./src/
|
||||
COPY ui/ ./ui/
|
||||
COPY scripts/ ./scripts/
|
||||
RUN npm run build
|
||||
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
# Runtime is only the bundled server + UI (no node_modules, no source, no mcp-only entry)
|
||||
COPY --from=build /app/dist/server.js ./dist/server.js
|
||||
COPY --from=build /app/dist/ui ./dist/ui
|
||||
EXPOSE 3001
|
||||
CMD ["node", "src/index.js"]
|
||||
CMD ["node", "dist/server.js"]
|
||||
|
||||
Reference in New Issue
Block a user