FROM openshift-ose-must-gather:v4.5.0-202007240519.p0 AS builder

COPY cnv-must-gather-*.tar.gz /must-gather/
RUN \
    cd /must-gather && \
    tar --strip-components 1 -xzf cnv-must-gather-*.tar.gz && \
    rm cnv-must-gather-*.tar.gz

#@follow_tag(ubi8-minimal:8-released)
FROM ubi8-minimal:8.2-349
RUN microdnf install -y tar rsync findutils gzip iproute tcpdump pciutils util-linux nftables hostname

# Copy must-gather required binaries
COPY --from=builder /usr/bin/openshift-must-gather /usr/bin/openshift-must-gather
COPY --from=builder /usr/bin/oc /usr/bin/oc

# Save original gather script
COPY --from=builder /usr/bin/gather /usr/bin/gather_original

# Copy all collection scripts to /usr/bin
COPY --from=builder /must-gather/collection-scripts/* /usr/bin/

# Copy node-gather resources to /etc
COPY --from=builder /must-gather/node-gather/node-gather-crd.yaml /etc/
COPY --from=builder /must-gather/node-gather/node-gather-ds.yaml /etc/

ENTRYPOINT /usr/bin/gather

LABEL com.redhat.component="cnv-must-gather-container" \
      name="container-native-virtualization/cnv-must-gather-rhel8" \
      version="v2.4.2" \
      release="1" \
      summary="CNV data gathering image" \
      io.openshift.expose-services="" \
      io.openshift.tags="data,images" \
      io.k8s.display-name="cnv-must-gather" \
      maintainer="The KubeVirt Project <kubevirt-dev@googlegroups.com" \
      description="CNV data gathering image"
