#@follow_tag(registry.redhat.io/ubi8/ubi-minimal:8.2)
FROM registry.redhat.io/ubi8/ubi-minimal:8.2-349 AS builder

ENV GOPATH=/go

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

COPY kubevirt-kvm-info-nfd-plugin-8ff7505e7c1da805f99b780b328323f42faf2b68.tar.gz /
RUN mkdir -p /go/src/github.com/kubevirt/kvm-info-nfd-plugin && \
    tar -xzf /kubevirt-kvm-info-nfd-plugin-8ff7505e7c1da805f99b780b328323f42faf2b68.tar.gz --strip-components 1 \
        -C /go/src/github.com/kubevirt/kvm-info-nfd-plugin && \
    cd /go/src/github.com/kubevirt/kvm-info-nfd-plugin && \
    make plugins

#@follow_tag(registry.redhat.io/ubi8/ubi-minimal:8.2)
FROM registry.redhat.io/ubi8/ubi-minimal:8.2-349

RUN mkdir -p /etc/kvm-version-info-nfd-plugin
COPY --from=builder /go/src/github.com/kubevirt/kvm-info-nfd-plugin/conf/kvm-version-info.json /etc/kvm-info-nfd-plugin
COPY --from=builder /go/src/github.com/kubevirt/kvm-info-nfd-plugin/cmd/kvm-version-info-nfd-plugin/kvm-version-info-nfd-plugin /usr/bin
COPY --from=builder /go/src/github.com/kubevirt/kvm-info-nfd-plugin/cmd/kvm-caps-info-nfd-plugin/kvm-caps-info-nfd-plugin /usr/bin

LABEL com.redhat.component="kubevirt-kvm-info-nfd-plugin-container" \
      name="container-native-virtualization/kubevirt-kvm-info-nfd-plugin" \
      version="v2.5.0" \
      upstream-version="v0.5.8-5-g8ff7505" \
      summary="Node-feature-discovery plugin to get the KVM HyperV feature support state" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,kvm,hyperv" \
      io.k8s.display-name="kubevirt-kvm-info-nfd-plugin" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com>" \
      description="Node-feature-discovery plugin to get HyperV feature state"
