# gadfly-reports daemon image. modernc.org/sqlite is pure Go, so the binary is
# CGO-free and the final image needs no libc / no C toolchain at build time.
FROM golang:1.26 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/gadfly-reports .

FROM alpine:3.20
RUN adduser -D -u 10001 app && mkdir -p /data && chown app /data
COPY --from=build /out/gadfly-reports /usr/local/bin/gadfly-reports
USER app
ENV GADFLY_REPORTS_ADDR=:8090 \
    GADFLY_REPORTS_DB=/data/gadfly-reports.db
EXPOSE 8090
VOLUME ["/data"]
ENTRYPOINT ["/usr/local/bin/gadfly-reports"]
CMD ["serve"]
