#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7 AS builder

RUN dnf install -y tar gzip

COPY ${CI_ARCHIVE_VM_IMPORT_OPERATOR} /
RUN tar -xvzf ${CI_ARCHIVE_VM_IMPORT_OPERATOR}

#@follow_tag(registry.redhat.io/rhel8-2-els/rhel)
FROM registry.redhat.io/rhel8-2-els/rhel:8.2-7

RUN mkdir /disks && \
    echo -e "[virt]\nname=virt\nprofiles=\nstate=enabled\nstream=8.2" > /etc/dnf/modules.d/virt.module && \
    echo -e "[llvm-toolset]\nname=llvm-toolset\nprofiles=\nstate=enabled\nstream=rhel8" > /etc/dnf/modules.d/llvm-toolset.module && \
    dnf -y update && \
    rm -rf /var/cache/yum && \
    dnf install -y \
        qemu-guest-agent \
        qemu-img \
        qemu-kvm \
        virt-v2v \
        virtio-win && \
    dnf clean all

ENV LIBGUESTFS_BACKEND=direct

COPY --from=builder vm-import-operator-${CI_UPSTREAM_COMMIT}/build/virtv2v/bin/entrypoint /usr/bin/entrypoint

ENTRYPOINT ["/usr/bin/entrypoint"]

LABEL com.redhat.component="vm-import-virtv2v-container" \
      name="container-native-virtualization/vm-import-virtv2v-rhel8" \
      version="${CI_CONTAINER_VERSION}" \
      release="${CI_CONTAINER_RELEASE}" \
      upstream-version="${CI_UPSTREAM_VERSION}" \
      upstream-vcs-ref="${CI_UPSTREAM_COMMIT}" \
      upstream-vcs-type="git" \
      summary="VM Import Operator - virt-v2v" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,operator,vmware,import" \
      io.k8s.display-name="vm-import-virtv2v" \
      maintainer="marnold@redhat.com,fdupont@redhat.com,pkliczew@redhat.com" \
      description="CNV VM Import virt-v2v"
