FROM golang:1.19 AS builder

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y libolm-dev

WORKDIR /build

COPY . .
RUN go build -ldflags="-s -w" -v ./cmd/matrix-prometheus

FROM debian:bullseye-slim

ARG DEBIAN_FRONTEND=noninteractive

RUN groupadd --gid 999 --system matrix-prometheus && useradd --gid 999 --system --uid 999 matrix-prometheus

RUN apt-get update && apt-get install -y ca-certificates libolm3

COPY --from=builder /build/matrix-prometheus /usr/local/bin/matrix-prometheus

USER matrix-prometheus

VOLUME /data
WORKDIR /data

CMD ["/usr/local/bin/matrix-prometheus"]
