-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (55 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
73 lines (55 loc) · 1.9 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
# Build stage
FROM golang:1.25-alpine AS builder
ARG VERSION=dev
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git build-base
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the MCP server
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \
-ldflags "-X main.version=${VERSION}" \
-o gitopia-mcp-server ./cmd/server
# Runtime stage
FROM ubuntu:24.04
# Set non-interactive frontend to avoid prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
wget \
bash \
ca-certificates \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Install git-remote-gitopia using the official script
RUN wget -O - https://get.gitopia.com | bash
# Create non-root user for security
RUN groupadd --system mcp && useradd --system --gid mcp mcp
# Ensure home directory exists and is owned by mcp
RUN mkdir -p /home/mcp && chown mcp:mcp /home/mcp
# Set HOME environment variable for the mcp user
ENV HOME=/home/mcp
# Copy the built binary
COPY --from=builder /app/gitopia-mcp-server /usr/local/bin/gitopia-mcp-server
# Set up MCP directories structure
RUN mkdir -p /home/mcp/.mcp/gitopia/workspace \
&& mkdir -p /home/mcp/.mcp/gitopia/config \
&& chown -R mcp:mcp /home/mcp/.mcp
# Switch to non-root user
USER mcp
WORKDIR /home/mcp/.mcp/gitopia/workspace
# Set environment variables for configuration
ENV MCP_WORKSPACE_PATH=/home/mcp/.mcp/gitopia/workspace
ENV GIT_USER_NAME="Gitopia MCP Server"
ENV GIT_USER_EMAIL="mcp@gitopia.com"
# Health check to ensure the server starts properly
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/usr/local/bin/gitopia-mcp-server", "--version"] || exit 1
# Default entrypoint
ENTRYPOINT ["/usr/local/bin/gitopia-mcp-server"]
# Default command (can be overridden)
CMD ["stdio"]