FROM openshift/golang-builder:1.10 AS builder

ENV GOPATH=/go

# Catch US Dockerfile changes that need to be propagated DS
ENV US_DOCKERFILE_MD5=3761af15cd2ed899f32a841825d21594

RUN yum install -y git golang

COPY containerized-data-importer-*.tar.gz /                                     
RUN mkdir -p /go/src/kubevirt.io/containerized-data-importer && \               
    tar -xzf containerized-data-importer-*.tar.gz --strip-components 1 \        
        -C /go/src/kubevirt.io/containerized-data-importer && \                 
    cd /go/src/kubevirt.io/containerized-data-importer && \                     
    echo "$US_DOCKERFILE_MD5  hack/build/docker/cdi-uploadserver/Dockerfile" > .md5sums && \
    md5sum -c .md5sums && rm .md5sums && \
    ./hack/build/build-go.sh build cmd/cdi-uploadserver 

FROM rhel7:7-released
RUN yum install -y qemu-img && yum clean all
COPY --from=builder /go/src/kubevirt.io/containerized-data-importer/_out/cmd/cdi-uploadserver/cdi-uploadserver /usr/bin/virt-cdi-uploadserver
ENTRYPOINT [ "/usr/bin/virt-cdi-uploadserver", "-alsologtostderr" ]

LABEL com.redhat.component="virt-cdi-uploadserver-container" \
      name="cnv-tech-preview/virt-cdi-uploadserver" \
      version="v1.4.1" \
      release="2" \
      summary="Upload server for the data fetching service" \
      io.openshift.expose-services="" \
      io.openshift.tags="data,images" \
      io.k8s.display-name="virt-cdi-uploadserver" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com" \
      description="Upload server for the data fetching service for CNV images"
