Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Dependencies
node_modules/
**/node_modules/

# Build outputs (we rebuild in Docker)
dist/
**/dist/
.turbo/
**/.turbo/

# Development files
*.log
*.local
.env
.env.*
!.env.example

# IDE
.vscode/
.idea/
*.swp
*.swo

# Test files
coverage/
**/coverage/
.nyc_output/
**/.nyc_output/

# Git
.git/
.gitignore

# Documentation
docs/
*.md
!README.md

# Demo and examples (not needed for server)
demo/
examples/

# Other packages not needed for MCP server
packages/dashboard/
packages/vscode/
packages/lsp/
packages/ai/
packages/galaxy/

# Docker
Dockerfile
docker-compose*.yml
.dockerignore

# macOS
.DS_Store

# Temporary files
tmp/
temp/
*.tmp
29 changes: 29 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Drift MCP Server - Docker Compose Configuration
# Copy this file to .env and adjust values as needed

# =============================================================================
# Project Configuration
# =============================================================================

# Path to the project you want to analyze
# This will be mounted into the container at /project
PROJECT_PATH=.

# Port to expose the MCP HTTP server on
DRIFT_PORT=3000

# =============================================================================
# Server Configuration
# =============================================================================

# Enable response caching (recommended for performance)
ENABLE_CACHE=true

# Enable rate limiting (recommended for shared deployments)
ENABLE_RATE_LIMIT=true

# Enable verbose logging (useful for debugging)
VERBOSE=false

# Skip warmup on startup (not recommended, but speeds up cold start)
SKIP_WARMUP=false
88 changes: 88 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Drift MCP Server Docker Image
# Multi-stage build for minimal production image

# =============================================================================
# Stage 1: Build
# =============================================================================
FROM node:20-slim AS builder

# Install pnpm
RUN corepack enable && corepack prepare pnpm@8.10.0 --activate

# Set working directory
WORKDIR /app

# Copy package files for dependency installation
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
COPY packages/core/package.json ./packages/core/
COPY packages/mcp/package.json ./packages/mcp/
COPY packages/detectors/package.json ./packages/detectors/
COPY packages/cli/package.json ./packages/cli/

# Install dependencies
RUN pnpm install --frozen-lockfile

# Copy source code
COPY packages/core/ ./packages/core/
COPY packages/mcp/ ./packages/mcp/
COPY packages/detectors/ ./packages/detectors/
COPY packages/cli/ ./packages/cli/
COPY tsconfig.json ./

# Build packages (core -> detectors -> mcp)
RUN pnpm --filter driftdetect-core build && \
pnpm --filter driftdetect-detectors build && \
pnpm --filter driftdetect-mcp build

# =============================================================================
# Stage 2: Production
# =============================================================================
FROM node:20-slim AS production

# Install pnpm
RUN corepack enable && corepack prepare pnpm@8.10.0 --activate

# Create non-root user for security
RUN groupadd --gid 1001 drift && \
useradd --uid 1001 --gid drift --shell /bin/bash --create-home drift

# Set working directory
WORKDIR /app

# Copy package files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/core/package.json ./packages/core/
COPY packages/mcp/package.json ./packages/mcp/
COPY packages/detectors/package.json ./packages/detectors/

# Install production dependencies only
RUN pnpm install --frozen-lockfile --prod

# Copy built artifacts from builder
COPY --from=builder /app/packages/core/dist ./packages/core/dist
COPY --from=builder /app/packages/mcp/dist ./packages/mcp/dist
COPY --from=builder /app/packages/detectors/dist ./packages/detectors/dist

# Create directory for mounting projects
RUN mkdir -p /project && chown drift:drift /project

# Switch to non-root user
USER drift

# Environment variables with defaults
ENV PORT=3000 \
PROJECT_ROOT=/project \
ENABLE_CACHE=true \
ENABLE_RATE_LIMIT=true \
VERBOSE=false \
NODE_ENV=production

# Expose HTTP port
EXPOSE 3000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "fetch('http://localhost:${PORT}/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"

# Run the HTTP server
CMD ["node", "packages/mcp/dist/bin/http-server.js"]
66 changes: 66 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Drift MCP Server - Docker Compose Configuration
#
# This configuration allows you to run the Drift MCP server as a containerized
# service accessible via HTTP. The MCP protocol is exposed via SSE (Server-Sent Events).
#
# Usage:
# 1. Build and start:
# docker compose up -d
#
# 2. With custom project path:
# PROJECT_PATH=/path/to/your/project docker compose up -d
#
# 3. View logs:
# docker compose logs -f
#
# 4. Stop:
# docker compose down
#
# Endpoints:
# - http://localhost:3000/health - Health check
# - http://localhost:3000/sse - SSE endpoint for MCP
# - http://localhost:3000/message - POST endpoint for MCP messages

services:
drift-mcp:
build:
context: .
dockerfile: Dockerfile
container_name: drift-mcp
restart: unless-stopped
ports:
- "${DRIFT_PORT:-3000}:3000"
volumes:
# Mount the project directory you want to analyze
- "${PROJECT_PATH:-.}:/project:ro"
# Optional: Mount .drift cache directory for persistence
- drift-cache:/project/.drift
environment:
# Server configuration
- PORT=3000
- PROJECT_ROOT=/project
# Feature flags
- ENABLE_CACHE=${ENABLE_CACHE:-true}
- ENABLE_RATE_LIMIT=${ENABLE_RATE_LIMIT:-true}
- VERBOSE=${VERBOSE:-false}
- SKIP_WARMUP=${SKIP_WARMUP:-false}
# Node.js configuration
- NODE_ENV=production
- NODE_OPTIONS=--max-old-space-size=4096
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/health').then(r => r.ok ? process.exit(0) : process.exit(1)).catch(() => process.exit(1))"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# Resource limits (adjust based on project size)
deploy:
resources:
limits:
memory: 4G
reservations:
memory: 1G

volumes:
drift-cache:
driver: local
3 changes: 2 additions & 1 deletion packages/mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
"drift-mcp": "./dist/bin/server.js"
"drift-mcp": "./dist/bin/server.js",
"drift-mcp-http": "./dist/bin/http-server.js"
},
"exports": {
".": {
Expand Down
Loading