-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (61 loc) · 1.72 KB
/
Dockerfile
File metadata and controls
79 lines (61 loc) · 1.72 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
77
78
79
# Build stage
FROM golang:1.25-alpine AS builder
# Install git for version info
RUN apk add --no-cache git
WORKDIR /app
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY *.go ./
# Get version info
ARG VERSION=dev
ARG COMMIT_HASH
ARG BUILD_TIME
# Build the binary with static linking
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-X main.version=${VERSION} -s -w -extldflags '-static'" \
-a -installsuffix cgo \
-o mcp-shell .
# Runtime stage
FROM alpine:3.22
# Install essential packages (fixed package names for Alpine)
RUN apk add --no-cache \
bash \
curl \
wget \
git \
make \
findutils \
grep \
sed \
gawk \
tar \
gzip \
unzip \
ca-certificates \
&& rm -rf /var/cache/apk/*
# Create non-root user for security
RUN addgroup -g 1000 mcpuser && \
adduser -D -s /bin/bash -u 1000 -G mcpuser mcpuser
# Create workspace directory
RUN mkdir -p /tmp/mcp-workspace && \
chown mcpuser:mcpuser /tmp/mcp-workspace
# Create config directory
RUN mkdir -p /etc/mcp-shell && \
chown mcpuser:mcpuser /etc/mcp-shell
# Copy binary from builder stage
COPY --from=builder /app/mcp-shell /usr/local/bin/mcp-shell
RUN chmod +x /usr/local/bin/mcp-shell
# Copy example security config
COPY security.yaml /etc/mcp-shell/security.yaml
# Set environment
ENV MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/security.yaml
ENV PATH="/usr/local/bin:${PATH}"
# Switch to non-root user
USER mcpuser
WORKDIR /tmp/mcp-workspace
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD echo '{"jsonrpc": "2.0", "method": "ping", "id": 1}' | timeout 2 mcp-shell || exit 1
ENTRYPOINT ["mcp-shell"]