-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (45 loc) · 2.07 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (45 loc) · 2.07 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
# ============================================================================
# Stage 1: Chef — prepare recipe for dependency caching
# ============================================================================
FROM rust:1.95-slim AS chef
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
RUN cargo install cargo-chef --locked
WORKDIR /app
# ============================================================================
# Stage 2: Planner — compute dependency recipe (cache-key)
# ============================================================================
FROM chef AS planner
COPY Cargo.toml Cargo.lock ./
COPY src/ src/
RUN cargo chef prepare --recipe-path recipe.json
# ============================================================================
# Stage 3: Builder — build dependencies (cached) then application
# ============================================================================
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies only — this layer is cached until Cargo.toml/lock change
RUN cargo chef cook --release --recipe-path recipe.json
# Now build the actual application
COPY Cargo.toml Cargo.lock ./
COPY src/ src/
RUN cargo build --release \
&& strip target/release/code-mcp
# ============================================================================
# Stage 4: Runtime — minimal distroless-style image
# ============================================================================
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
git \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --create-home --shell /bin/false mcp
COPY --from=builder /app/target/release/code-mcp /usr/local/bin/code-mcp
USER mcp
WORKDIR /project
EXPOSE 8080
# All CLI flags are passed directly via CMD/args — ENTRYPOINT is the binary
ENTRYPOINT ["code-mcp"]
# Sensible defaults: bind all interfaces, project root = /project
CMD ["--bind", "0.0.0.0:8080", "--project", "/project"]