# Multi-stage build for x.ai Grok MCP Server
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install all dependencies (including devDependencies for build)
RUN npm ci
# Copy source files
COPY tsconfig.json ./
COPY src ./src
# Build TypeScript
RUN npm run build
# Runtime stage
FROM node:20-alpine
WORKDIR /app
# Copy built files and dependencies from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
# Make the entrypoint executable
RUN chmod +x dist/index.js
# Set environment variable
ENV NODE_ENV=production
# Run the server
ENTRYPOINT ["node", "dist/index.js"]