cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
packages/mcp-server/Dockerfile
78lines · modecode
| 1 | # Dockerfile for Cloudflare MCP Server |
| 2 | # |
| 3 | # This Dockerfile builds a Docker image for the MCP Server. |
| 4 | # |
| 5 | # To build the image locally: |
| 6 | # docker build -f packages/mcp-server/Dockerfile -t cloudflare-mcp:local . |
| 7 | # |
| 8 | # To run the image: |
| 9 | # docker run -i cloudflare-mcp:local [OPTIONS] |
| 10 | # |
| 11 | # Common options: |
| 12 | # --tool=<name> Include specific tools |
| 13 | # --resource=<name> Include tools for specific resources |
| 14 | # --operation=read|write Filter by operation type |
| 15 | # --client=<type> Set client compatibility (e.g., claude, cursor) |
| 16 | # --transport=<type> Set transport type (stdio or http) |
| 17 | # |
| 18 | # For a full list of options: |
| 19 | # docker run -i cloudflare-mcp:local --help |
| 20 | # |
| 21 | # Note: The MCP server uses stdio transport by default. Docker's -i flag |
| 22 | # enables interactive mode, allowing the container to communicate over stdin/stdout. |
| 23 | |
| 24 | # Build stage |
| 25 | FROM node:24-alpine AS builder |
| 26 | |
| 27 | # Install bash for build script |
| 28 | RUN apk add --no-cache bash openssl |
| 29 | |
| 30 | # Set working directory |
| 31 | WORKDIR /build |
| 32 | |
| 33 | # Copy entire repository |
| 34 | COPY . . |
| 35 | |
| 36 | # Install all dependencies and build everything |
| 37 | RUN yarn install --frozen-lockfile && \ |
| 38 | yarn build && \ |
| 39 | # Remove the symlink to the SDK so it doesn't interfere with the explicit COPY below |
| 40 | rm -Rf packages/mcp-server/node_modules/cloudflare |
| 41 | |
| 42 | FROM denoland/deno:alpine-2.7.1 |
| 43 | |
| 44 | # Install node and npm |
| 45 | RUN apk add --no-cache nodejs npm |
| 46 | |
| 47 | ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib |
| 48 | |
| 49 | # Add non-root user |
| 50 | RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001 |
| 51 | |
| 52 | # Set working directory |
| 53 | WORKDIR /app |
| 54 | |
| 55 | # Copy the built mcp-server dist directory |
| 56 | COPY --from=builder /build/packages/mcp-server/dist ./ |
| 57 | |
| 58 | # Copy node_modules from mcp-server (includes all production deps) |
| 59 | COPY --from=builder /build/packages/mcp-server/node_modules ./node_modules |
| 60 | |
| 61 | # Copy the built cloudflare into node_modules |
| 62 | COPY --from=builder /build/dist ./node_modules/cloudflare |
| 63 | |
| 64 | # Change ownership to nodejs user |
| 65 | RUN chown -R nodejs:nodejs /app |
| 66 | RUN chown -R nodejs:nodejs /deno-dir |
| 67 | |
| 68 | # Switch to non-root user |
| 69 | USER nodejs |
| 70 | |
| 71 | # The MCP server uses stdio transport by default |
| 72 | # No exposed ports needed for stdio communication |
| 73 | |
| 74 | # Set the entrypoint to the MCP server |
| 75 | ENTRYPOINT ["node", "index.js"] |
| 76 | |
| 77 | # Allow passing arguments to the MCP server |
| 78 | CMD [] |
| 79 | |