-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.13 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
44
45
46
47
48
49
50
51
52
53
# Multi-stage build for TypeScript MCP Server
FROM node:22.16.0-alpine AS base
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init
# Create app directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
FROM base AS deps
RUN npm ci --only=production && npm cache clean --force
# Development dependencies for building
FROM base AS build-deps
RUN npm ci
# Build stage
FROM build-deps AS build
COPY . .
RUN npm run build
# Production stage
FROM base AS production
# Copy production dependencies
COPY --from=deps /app/node_modules ./node_modules
# Copy built application
COPY --from=build /app/dist ./dist
COPY --from=build /app/src ./src
COPY --from=build /app/package*.json ./
COPY --from=build /app/tsconfig.json ./
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 -G nodejs
# Change ownership of the app directory
RUN chown -R nodejs:nodejs /app
USER nodejs
# Environment variables
ENV NODE_ENV=production
# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
# Default command - stdio mode for MCP clients
CMD ["npm", "start"]