# {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

# trixie (Debian 13), not bookworm: fastembed/ort's downloaded prebuilt
# ONNX Runtime static libs reference glibc >= 2.38 symbols (e.g.
# `__isoc23_strtoll`) that bookworm's glibc 2.36 doesn't have, which fails
# at link time. The runtime stage below must match this glibc version too,
# since the final binary is linked against it.
FROM rust:1-slim-trixie AS builder
WORKDIR /app

# rusqlite's "bundled" feature compiles vendored SQLite (and sqlite-vec) from
# source, which needs a C toolchain — `rust:*-slim` doesn't ship one by
# default the way the full `rust:*` image does.
RUN apt-get update \
    && apt-get install -y --no-install-recommends build-essential pkg-config \
    && rm -rf /var/lib/apt/lists/*

COPY Cargo.toml Cargo.lock* ./
COPY src ./src
COPY mcp_store.db ./mcp_store.db

RUN cargo build --release

# mcp_store.db leaves the Rust generator with an empty semantic_endpoints
# table (vectors are computed here, not by mcpify itself — see the plan's
# embeddings decision), so it must be populated before the image is usable.
RUN ./target/release/{{ project_name }}-populate-embeddings

# `fastembed`/`ort` (Story R6) may dynamically link an ONNX Runtime shared
# library rather than statically linking it — if `cargo build --release`
# above succeeds but the binary fails at runtime with a missing
# `libonnxruntime.so`, this runtime stage needs an explicit
# `COPY --from=builder` of that library (or a system package providing it).
# Flagged here for verification once R6 lands `services/embedding_service.rs`
# and this Dockerfile gets a real end-to-end build.
FROM debian:trixie-slim AS runtime
WORKDIR /app
RUN apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/{{ project_name }} ./{{ project_name }}
COPY --from=builder /app/target/release/{{ project_name }}-healthcheck ./{{ project_name }}-healthcheck
COPY --from=builder /app/mcp_store.db ./mcp_store.db

HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD ["./{{ project_name }}-healthcheck"]

ENTRYPOINT ["./{{ project_name }}"]
