Skip to content

Commit b73421e

Browse files
committed
fixed docker build config
1 parent 7541289 commit b73421e

File tree

2 files changed

+77
-15
lines changed

2 files changed

+77
-15
lines changed

Server/.dockerignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Node.js
2+
node_modules
3+
npm-debug.log
4+
yarn-debug.log
5+
yarn-error.log
6+
7+
# Build outputs
8+
build
9+
dist
10+
.tsbuildinfo
11+
12+
# Development files
13+
.git
14+
.github
15+
.vscode
16+
.idea
17+
*.md
18+
.gitignore
19+
.env
20+
.env.*
21+
*.log
22+
23+
# Test files
24+
test
25+
__tests__
26+
*.test.ts
27+
*.spec.ts
28+
29+
# Miscellaneous
30+
.DS_Store
31+
Thumbs.db
32+
*.swp
33+
*.swo

Server/Dockerfile

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,58 @@
1-
# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
2-
FROM node:18-alpine AS release
1+
# Multi-stage build for optimized production image
2+
FROM node:18-alpine AS builder
33

4-
# Create app directory
4+
# Set working directory
55
WORKDIR /app
66

7-
# Copy package files
8-
COPY package*.json tsconfig.json ./
7+
# Copy package files for dependency installation
8+
COPY package.json package-lock.json ./
9+
10+
# Install dependencies with cache optimization
11+
RUN --mount=type=cache,target=/root/.npm \
12+
npm ci
13+
14+
# Copy TypeScript configuration and source code
15+
COPY tsconfig.json ./
16+
COPY src ./src
17+
18+
# Build the project
19+
RUN npm run build
920

10-
# Install dependencies with caching
11-
RUN --mount=type=cache,target=/root/.npm npm install
21+
# Production stage with minimal dependencies
22+
FROM node:18-alpine AS production
1223

13-
# Copy the rest of the project source
14-
COPY . .
24+
# Set working directory
25+
WORKDIR /app
1526

1627
# Set production environment
1728
ENV NODE_ENV=production
1829

19-
# Build the project
20-
RUN npm run build
30+
# Copy package files
31+
COPY package.json package-lock.json ./
32+
33+
# Install production dependencies only
34+
RUN --mount=type=cache,target=/root/.npm \
35+
npm ci --omit=dev
36+
37+
# Copy built application from builder stage
38+
COPY --from=builder /app/build ./build
2139

22-
# Set the user to non-root
23-
USER node
40+
# Create a non-root user to run the app
41+
RUN addgroup -g 1001 -S nodejs && \
42+
adduser -S nodejs -u 1001 -G nodejs
2443

25-
# Expose WebSocket port, default 8090
44+
# Set ownership to the non-root user
45+
RUN chown -R nodejs:nodejs /app
46+
47+
# Switch to non-root user
48+
USER nodejs
49+
50+
# Expose WebSocket port
2651
EXPOSE 8090
2752

28-
# Command to run the MCP server. Use ENTRYPOINT instead of CMD for better compatibility
53+
# Health check to ensure the application is running
54+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
55+
CMD wget --no-verbose --tries=1 --spider http://localhost:8090/health || exit 1
56+
57+
# Command to run the MCP server
2958
ENTRYPOINT ["node", "build/index.js"]

0 commit comments

Comments
 (0)