Dockerfileā¢1.61 kB
# Multi-stage Docker build for MCP Server
FROM node:18-alpine AS node-base
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy source code
COPY server.js ./
COPY mcp-config.json ./
COPY .env.example ./.env
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S mcp -u 1001
# Set permissions
RUN chown -R mcp:nodejs /app
USER mcp
# Expose port
EXPOSE 3000
# Health check
HEALTHCHEK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start command
CMD ["node", "server.js"]
# Python alternative stage
FROM python:3.11-alpine AS python-base
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apk add --no-cache gcc musl-dev curl
# Copy requirements
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy source code
COPY server.py ./
COPY mcp-config.json ./
COPY .env.example ./.env
# Create non-root user
RUN addgroup -g 1001 -S python && \
adduser -S mcp -u 1001 -G python
# Set permissions
RUN chown -R mcp:python /app
USER mcp
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start command
CMD ["python", "server.py", "--http"]
# Production stage (defaults to Node.js)
FROM node-base AS production
# Production optimizations
ENV NODE_ENV=production
ENV LOG_LEVEL=info
# Final stage
FROM production AS final