FROM rhel7:7-released AS builder

ENV GOPATH=/go

RUN yum install -y git golang

COPY cpu-model-nfd-plugin-*.tar.gz /
RUN mkdir -p /go/src/github.com/ksimon1/cpu-model-nfd-plugin && \
    tar -xzf /cpu-model-nfd-plugin-*.tar.gz --strip-components 1 \
        -C /go/src/github.com/ksimon1/cpu-model-nfd-plugin && \
    cd /go/src/github.com/ksimon1/cpu-model-nfd-plugin/cmd/cpu-model-nfd-plugin && \
    go build -v

FROM rhel7:7-released
RUN mkdir -p /plugin/dest
COPY --from=builder \
     /go/src/github.com/ksimon1/cpu-model-nfd-plugin/cmd/cpu-model-nfd-plugin/cpu-model-nfd-plugin && \
     /plugin/dest

LABEL com.redhat.component="kubevirt-cpu-model-nfd-plugin-container" \
      name="cnv-tech-preview/kubevirt-cpu-model-nfd-plugin" \
      version="v1.4.1" \
      summary="Node-feature-discovery plugin to get host supported cpu models" \
      io.openshift.expose-services="" \
      io.openshift.tags="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"
