Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
95 lines (78 loc) · 4.33 KB
/
Copy pathDockerfile
File metadata and controls
95 lines (78 loc) · 4.33 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
93
94
95
FROM ghcr.io/astral-sh/uv:0.13.10@sha256:a3ea1357342c1a4bf9a0c53a3deb1b55379aefa037338d8113d5771efa01774f AS uv
# The crate the project depends on, cgr-graph-rs, is built from rust/ during
# uv sync. Debian's cargo trails its locked dependencies (trixie ships rustc
# 1.85; tree-sitter-language needs 1.90), so the toolchain comes from here,
# no older than RUST_TOOLCHAIN in .clusterfuzzlite/Dockerfile, which the fuzz
# build proves the crate with on every pull request.
FROM rust:1.100.0-slim-trixie@sha256:6f14b2b4b278ec0d50aa1d69541c304ce0f95e0f6268487aa9924af1c2e9aebe AS rust
FROM python:3.15-slim@sha256:65a65fc7b30b06cb6df4930fd4650697cb23f4c2698ab81fc87e4b031bc36928 AS builder
COPY --from=uv /uv /uvx /bin/
COPY --chmod=755 scripts/distrust_ca_roots.sh /usr/local/sbin/
# Naming ca-certificates upgrades it to the archive's current release: the
# pinned base is a snapshot whose CA store can predate a root's removal, as
# with emSign ECC Root CA - G3 in October 2026. The eMudhra roots the archive
# still ships are then deselected. cargo fetches through this store.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates cmake build-essential git libssl-dev zlib1g-dev libzstd-dev && \
rm -rf /var/lib/apt/lists/* && \
distrust_ca_roots.sh
COPY --from=rust /usr/local/rustup /usr/local/rustup
COPY --from=rust /usr/local/cargo /usr/local/cargo
ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo PATH=/usr/local/cargo/bin:$PATH
WORKDIR /app
# uv installs its managed Python interpreter outside the project directory by
# default ($HOME/.local/share/uv/python, i.e. /root/.local when run as root).
# .venv only symlinks to that interpreter, so pin the install dir under /app
# and copy it into the final stage too, or the venv's python symlink dangles
# once /root is left behind.
#
# uv only populates this directory when it actually downloads a managed
# interpreter -- if the pinned Python version ever matched this image's
# system Python, uv would use that instead and never create the
# directory, and the unconditional COPY below would fail the build
# outright. only-managed rules that out: uv always uses (and downloads
# if needed) its own interpreter, never the system one.
ENV UV_PYTHON_INSTALL_DIR=/app/.uv-python
ENV UV_PYTHON_PREFERENCE=only-managed
# .python-version must arrive with the manifests: without it this first sync
# falls back to the newest managed Python allowed by requires-python (which
# moves with each uv release), and the later sync, once COPY . . brings in the
# pin, rebuilds .venv on the pinned version. --no-install-local leaves out
# the project and cgr-graph-rs, a path dependency built from rust/ (with the
# cargo above), as neither source is here until COPY . . brings it.
COPY pyproject.toml uv.lock .python-version ./
RUN uv sync --frozen --no-dev --extra treesitter-full --extra memgraph --no-install-local --no-binary-package pymgclient
COPY . .
RUN uv sync --frozen --no-dev --extra treesitter-full --extra memgraph --no-binary-package pymgclient
FROM python:3.15-slim@sha256:65a65fc7b30b06cb6df4930fd4650697cb23f4c2698ab81fc87e4b031bc36928
COPY --chmod=755 scripts/distrust_ca_roots.sh /usr/local/sbin/
# The CA store as in the builder: the LLM clients verify TLS against it
# through httpx2's truststore context, not certifi.
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates ripgrep libssl3 zlib1g libzstd1 && \
rm -rf /var/lib/apt/lists/* && \
distrust_ca_roots.sh
RUN useradd --create-home appuser
USER appuser
WORKDIR /app
COPY --from=builder --chown=appuser:appuser /app/.uv-python /app/.uv-python
COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv
COPY --from=builder --chown=appuser:appuser /app/codebase_rag /app/codebase_rag
COPY --from=builder --chown=appuser:appuser /app/codec /app/codec
COPY --from=builder --chown=appuser:appuser /app/cgr /app/cgr
COPY --from=builder --chown=appuser:appuser /app/pyproject.toml /app/pyproject.toml
ENV PATH="/app/.venv/bin:$PATH"
COPY --chmod=755 <<'EOF' /app/entrypoint.sh
#!/bin/sh
ARCH=$(uname -m)
case "$ARCH" in
x86_64) LIBDIR="/lib/x86_64-linux-gnu" ;;
aarch64) LIBDIR="/lib/aarch64-linux-gnu" ;;
*) LIBDIR="/lib" ;;
esac
export LD_PRELOAD="$LIBDIR/libz.so.1:$LIBDIR/libzstd.so.1"
exec code-graph-rag "$@"
EOF
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["mcp-server"]