# ── Build stage ──────────────────────────────────────────────
FROM rust:1-bookworm AS builder

WORKDIR /app

# Cache dependency build
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo 'fn main() {}' > src/main.rs && \
    cargo build --release && \
    rm -rf src

# Build the actual binary
COPY src/ src/
RUN touch src/main.rs && cargo build --release

# ── Runtime stage ────────────────────────────────────────────
FROM debian:bookworm-slim

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

WORKDIR /app

COPY --from=builder /app/target/release/llm-proxy /app/llm-proxy
COPY static/ /app/static/

# Default config location
VOLUME ["/app/config", "/app/data"]

EXPOSE 8080

ENV RUST_LOG=info

ENTRYPOINT ["/app/llm-proxy"]
