#@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

# Catch US Dockerfile changes that need to be propagated DS
ENV US_DOCKERFILE_MD5=9506b6275a3fcbfcef62967892be762d

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

COPY hostpath-provisioner-*.tar.gz /                                     
RUN mkdir -p /go/src/kubevirt.io/hostpath-provisioner && \               
    tar -xzf hostpath-provisioner-*.tar.gz --strip-components 1 \        
        -C /go/src/kubevirt.io/hostpath-provisioner && \                 
    cd /go/src/kubevirt.io/hostpath-provisioner && \                     
    echo "$US_DOCKERFILE_MD5  ./Dockerfile" > .md5sums && \
    md5sum -c .md5sums && rm .md5sums && \
    GOFLAGS=-mod=vendor \
    make hostpath-provisioner

#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7
COPY --from=builder /go/src/kubevirt.io/hostpath-provisioner/_out/hostpath-provisioner /usr/bin/hostpath-provisioner
ENTRYPOINT [ "/usr/bin/hostpath-provisioner" ]

LABEL com.redhat.component="hostpath-provisioner-container" \
      name="container-native-virtualization/hostpath-provisioner-rhel8" \
      version="v2.4.6" \
      release="2" \
      summary="Hostpath storage provisioner" \
      io.openshift.expose-services="" \
      io.openshift.tags="storage" \
      io.k8s.display-name="hostpath-provisioner" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com" \
      description="Hostpath provisioner for CNV VM disk images"
