FROM golang:1.26-bookworm AS builder

WORKDIR /app
COPY infra/webhook/ .
RUN go mod download && \
    CGO_ENABLED=0 GOOS=linux go build -o webhook .

FROM scratch
COPY --from=builder /app/webhook /webhook
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
EXPOSE 9001
ENTRYPOINT ["/webhook"]