#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7 AS builder

ENV GOPATH=/go
ENV VERSION="v1.0.1-3-gd6653c8"

RUN echo -e "[go-toolset]\nname=go-toolset\nprofiles=\nstate=enabled\nstream=rhel8" > /etc/dnf/modules.d/go-toolset.module \
    && dnf install -y git sed go-compilers-golang-compiler make

COPY kubevirt-metrics-collector-d6653c8d6e610afb8208e00102f1771fbf4c13a0.tar.gz /
RUN mkdir -p /go/src/github.com/fromanirh/kubevirt-metrics-collector && \
    tar -xzf /kubevirt-metrics-collector-d6653c8d6e610afb8208e00102f1771fbf4c13a0.tar.gz --strip-components 1 \
        -C /go/src/github.com/fromanirh/kubevirt-metrics-collector
WORKDIR ${GOPATH}/src/github.com/fromanirh/kubevirt-metrics-collector
RUN make binary


#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7
RUN mkdir -p /etc/kubevirt-metrics-collector
COPY --from=builder /go/src/github.com/fromanirh/kubevirt-metrics-collector/cluster/kubevirt-metrics-collector.json /etc/kubevirt-metrics-collector/config.json
COPY --from=builder /go/src/github.com/fromanirh/kubevirt-metrics-collector/cmd/kubevirt-metrics-collector/kubevirt-metrics-collector /usr/sbin/kubevirt-metrics-collector
ENTRYPOINT [ "/usr/sbin/kubevirt-metrics-collector", "/etc/kubevirt-metrics-collector/config.json" ]

LABEL com.redhat.component="kubevirt-metrics-collector-container" \
      name="container-native-virtualization/kubevirt-metrics-collector" \
      version="v2.4.5" \
      upstream-version="v1.0.1-3-gd6653c8" \
      summary="Prometheus endpoint for the VM processes" \
      upstream-vcs-type="git" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,metrics" \
      io.k8s.display-name="kubevirt-metrics-collector" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com" \
      description="Prometheus endpoint to gather metrics about the VM processes"
