FROM golang:1.25-alpine AS builder

RUN apk add --no-cache git

WORKDIR /build

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o age-api .

FROM gcr.io/distroless/static-debian12:nonroot

COPY --from=builder /build/age-api /usr/local/bin/age-api
COPY --from=builder /build/config.yaml /etc/age-api/config.yaml

ENV CONFIG_PATH=/etc/age-api/config.yaml

EXPOSE 8080

ENTRYPOINT ["age-api"]
