-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.local
More file actions
76 lines (61 loc) · 2.23 KB
/
Copy pathDockerfile.local
File metadata and controls
76 lines (61 loc) · 2.23 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
76
# Dockerfile.local - MCP Hub with embedded local MCP server support
# This image includes Node.js, Python, and Rust (uv) for running local MCP servers
# within the same container. Use this when you want to run stdio-based MCP servers
# without external dependencies or separate containers.
#
# Size: ~800MB (includes Node.js, Python, and development tools)
# Use when:
# - You want to run Node.js, Python, or Rust-based MCP servers without Docker transport
# - You want a self-contained deployment with all runtimes included
# - You're running the hub and local servers in the same container
#
# Example usage:
# docker build -f Dockerfile.local -t mcp-hub:local .
# docker run -d -p 8080:8080 -v $(pwd)/config.json:/app/config.json:ro mcp-hub:local
# Stage 1: Build the Go binary
FROM golang:1.23-alpine AS builder
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum* ./
# Download dependencies
RUN if [ -f go.sum ]; then go mod download; fi
# Copy source code
COPY . .
# Build the binary with optimizations
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags='-w -s -extldflags "-static"' \
-a \
-o mcp-hub \
./cmd/mcp-hub
# Stage 2: Runtime with Node.js, Python, uv, and curl
FROM node:20-bookworm-slim
# Install additional tools needed for MCP servers
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-venv \
curl \
ca-certificates \
git \
bash \
&& rm -rf /var/lib/apt/lists/*
# Install uv using the official installer instead of pip
# uv is a fast Python package installer written in Rust
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.local/bin/uv /usr/local/bin/uv
# Copy the mcp-hub binary from builder
COPY --from=builder /build/mcp-hub /usr/local/bin/mcp-hub
# Use existing node user (UID/GID 1000) instead of creating a new user
RUN groupadd --gid 980 docker && \
usermod -aG docker node && \
mkdir -p /app /plugins && \
chown -R node:node /app /plugins
# Set working directory
WORKDIR /app
# Switch to non-root user
USER node
# Expose the default port
EXPOSE 8080
# The binary accepts --config flag for configuration file path
ENTRYPOINT ["/usr/local/bin/mcp-hub"]
CMD ["--config", "/app/config.json"]