FROM ubi8-minimal:8.2-339 AS builder

ENV GOPATH=/go

RUN microdnf install -y go-compilers-golang-compiler tar gzip

COPY ${CI_ARCHIVE_KUBEVIRT_CPU_MODEL_NFD_PLUGIN} /
RUN mkdir -p /go/src/kubevirt.io/cpu-nfd-plugin && \
    tar -xzf /${CI_ARCHIVE_KUBEVIRT_CPU_MODEL_NFD_PLUGIN} --strip-components 1 \
        -C /go/src/kubevirt.io/cpu-nfd-plugin && \
    cd /go/src/kubevirt.io/cpu-nfd-plugin/cmd/cpu-nfd-plugin && \
    GOPROXY=off GOFLAGS=-mod=vendor go build -v

FROM ubi8-minimal:8.2-339
RUN mkdir -p /plugin/dest
COPY --from=builder \
     /go/src/kubevirt.io/cpu-nfd-plugin/cmd/cpu-nfd-plugin/cpu-nfd-plugin \
     /plugin/dest

LABEL com.redhat.component="kubevirt-cpu-model-nfd-plugin-container" \
      name="container-native-virtualization/kubevirt-cpu-model-nfd-plugin" \
      version="${CI_CONTAINER_VERSION}" \
      upstream-version="v${CI_UPSTREAM_VERSION}" \
      summary="Node-feature-discovery plugin to get host supported cpu models and cpu features" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,cpu" \
      io.k8s.display-name="kubevirt-cpu-model-nfd-plugin" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com>" \
      description="Node-feature-discovery plugin to get host supported cpu models and cpu features"
