-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (58 loc) · 2.22 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (58 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Dockerfile for Stainless MCP Server
#
# This Dockerfile builds a Docker image for the MCP Server.
#
# To build the image locally:
# docker build -f packages/mcp-server/Dockerfile -t stainlessapi/stainless-mcp:local .
#
# To run the image:
# docker run -i stainlessapi/stainless-mcp:local [OPTIONS]
#
# Common options:
# --tool=<name> Include specific tools
# --resource=<name> Include tools for specific resources
# --operation=read|write Filter by operation type
# --client=<type> Set client compatibility (e.g., claude, cursor)
# --transport=<type> Set transport type (stdio or http)
#
# For a full list of options:
# docker run -i stainlessapi/stainless-mcp:local --help
#
# Note: The MCP server uses stdio transport by default. Docker's -i flag
# enables interactive mode, allowing the container to communicate over stdin/stdout.
# Build stage
FROM node:20-alpine AS builder
# Enable corepack to use pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install bash for build script
RUN apk add --no-cache bash openssl
# Set working directory
WORKDIR /build
# Copy entire repository
COPY . .
# Install all dependencies and build everything
RUN pnpm install --frozen-lockfile && \
pnpm build
# Production stage
FROM node:20-alpine
# Add non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
# Set working directory
WORKDIR /app
# Copy the built mcp-server preserving directory structure
COPY --from=builder /build/packages/mcp-server/dist ./packages/mcp-server/dist
COPY --from=builder /build/packages/mcp-server/node_modules ./packages/mcp-server/node_modules
# Copy node_modules from root (pnpm hoists dependencies here)
COPY --from=builder /build/node_modules ./node_modules
# Copy the built @stainless-api/sdk into node_modules
COPY --from=builder /build/dist ./node_modules/@stainless-api/sdk
# Change ownership to nodejs user
RUN chown -R nodejs:nodejs /app
# Switch to non-root user
USER nodejs
# The MCP server uses stdio transport by default
# No exposed ports needed for stdio communication
# Set the entrypoint to the MCP server
ENTRYPOINT ["node", "packages/mcp-server/dist/index.js"]
# Allow passing arguments to the MCP server
CMD []