forked from CodeGraphContext/CodeGraphContext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.mcp
More file actions
92 lines (72 loc) · 3.18 KB
/
Dockerfile.mcp
File metadata and controls
92 lines (72 loc) · 3.18 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
80
81
82
83
84
85
86
87
88
89
90
91
92
# Multi-stage build for CGC hosted MCP server (HTTP transport)
#
# Bundles CGC core + cgc-plugin-otel + cgc-plugin-xdebug into a single image
# that serves the Model Context Protocol over HTTP on port 8045.
#
# Build:
# docker build -f Dockerfile.mcp -t cgc-mcp:latest .
#
# Run (credentials supplied at runtime — never baked in):
# docker run -e DATABASE_TYPE=neo4j \
# -e NEO4J_URI=bolt://neo4j:7687 \
# -e NEO4J_USERNAME=neo4j \
# -e NEO4J_PASSWORD=<secret> \
# -p 8045:8045 cgc-mcp:latest
# ── Builder stage ─────────────────────────────────────────────────────────────
FROM python:3.12-slim AS builder
WORKDIR /app
# System build dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
make \
git \
&& rm -rf /var/lib/apt/lists/*
# Install CGC core
COPY pyproject.toml README.md LICENSE MANIFEST.in ./
COPY src/ ./src/
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir .
# Install cgc-plugin-otel
COPY plugins/cgc-plugin-otel/ ./plugins/cgc-plugin-otel/
RUN pip install --no-cache-dir ./plugins/cgc-plugin-otel
# Install cgc-plugin-xdebug
COPY plugins/cgc-plugin-xdebug/ ./plugins/cgc-plugin-xdebug/
RUN pip install --no-cache-dir ./plugins/cgc-plugin-xdebug
# ── Production stage ──────────────────────────────────────────────────────────
FROM python:3.12-slim
WORKDIR /app
# Runtime system dependencies (curl required for HEALTHCHECK)
RUN apt-get update && apt-get install -y \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Non-root user
RUN groupadd --gid 1001 cgc && \
useradd --uid 1001 --gid cgc --shell /bin/sh --create-home cgc
# Copy installed Python packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin/cgc /usr/local/bin/cgc
COPY --from=builder /usr/local/bin/codegraphcontext /usr/local/bin/codegraphcontext
# Copy CGC core source
COPY --from=builder /app/src /app/src
# Copy plugin sources (entry-point discovery requires the installed packages;
# source copies allow live plugin inspection if needed)
COPY --from=builder /app/plugins/cgc-plugin-otel /app/plugins/cgc-plugin-otel
COPY --from=builder /app/plugins/cgc-plugin-xdebug /app/plugins/cgc-plugin-xdebug
# Directories owned by the non-root user
RUN mkdir -p /workspace /home/cgc/.codegraphcontext && \
chown -R cgc:cgc /workspace /home/cgc/.codegraphcontext
# Runtime environment — no secrets here
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV CGC_HOME=/home/cgc/.codegraphcontext
# MCP HTTP server port
EXPOSE 8045
WORKDIR /workspace
USER cgc
# Health check via the /healthz HTTP endpoint exposed by the MCP server
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -f http://localhost:8045/healthz || exit 1
# Start the MCP server over HTTP transport
CMD ["cgc", "mcp", "start", "--transport", "http"]