# ------ Builder Stage --------------
FROM rust:1.95 AS builder
WORKDIR /app
RUN cargo install cargo-auditable

COPY Cargo.toml Cargo.lock ./
RUN cargo fetch
COPY src ./src
RUN cargo auditable build --release --locked

# ------- Cosign Stage ---------------

FROM ghcr.io/sigstore/cosign/cosign:v3.0.6 AS cosign

# ------- Production Stage -----------
FROM debian:13-slim

LABEL org.opencontainers.image.authors="joseph.wortmann@gmail.com" \
    org.opencontainers.image.url="https://github.com/hyper-mcp-rs/hyper-mcp-remote" \
    org.opencontainers.image.source="https://github.com/hyper-mcp-rs/hyper-mcp-remote" \
    org.opencontainers.image.vendor="github.com/hyper-mcp-rs/hyper-mcp-remote" \
    io.modelcontextprotocol.server.name="io.github.hyper-mcp-rs/hyper-mcp-remote"

RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

COPY --from=cosign /ko-app/cosign /usr/local/bin/cosign

WORKDIR /app
COPY --from=builder /app/target/release/hyper-mcp-remote /usr/local/bin/hyper-mcp-remote
ENTRYPOINT ["/usr/local/bin/hyper-mcp-remote"]
