-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (37 loc) · 1.16 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (37 loc) · 1.16 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
# 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 (if go.sum exists)
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: Minimal runtime with Docker CLI
FROM alpine:latest
# Install Docker CLI (for Docker transport support)
RUN apk add --no-cache docker-cli ca-certificates
# Copy the binary from builder
COPY --from=builder /build/mcp-hub /usr/local/bin/mcp-hub
# Create non-root user and add to docker group
RUN addgroup -g 980 docker && \
addgroup -g 1000 mcpuser && \
adduser -D -u 1000 -G mcpuser mcpuser && \
adduser mcpuser docker && \
mkdir -p /app && \
chown -R mcpuser:mcpuser /app
# Set working directory
WORKDIR /app
# Switch to non-root user
USER mcpuser
# 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"]