FROM golang:1.22-bookworm AS builder

ENV GOTOOLCHAIN=auto

ARG VERSION=v2.10.2

WORKDIR /app
RUN git clone --depth 1 --branch ${VERSION} https://github.com/sigbit/mcp-auth-proxy .
RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -trimpath -ldflags "-w -s" -o /app/bin/mcp-auth-proxy .

FROM scratch

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/bin/mcp-auth-proxy /mcp-auth-proxy

ENV DATA_PATH=/data

ENTRYPOINT ["/mcp-auth-proxy"]
