#@follow_tag(ubi8-minimal:8-released)
FROM ubi8-minimal:8.1-409 AS builder

ENV OPERATOR=/usr/local/bin/hyperconverged-cluster-operator \
    USER_UID=1001 \
    USER_NAME=hyperconverged-cluster-operator

ENV GOPATH=/go
ENV SRC_DIR=${GOPATH}/src/github.com/kubevirt/hyperconverged-cluster-operator

RUN microdnf install -y tar gzip rsync sed go-compilers-golang-compiler make

COPY hyperconverged-cluster-operator-b88799c8bb4f414b65949497d2f1e05eaaf5655f.tar.gz /
RUN mkdir -p "$SRC_DIR" \
    && tar -xzf "hyperconverged-cluster-operator-b88799c8bb4f414b65949497d2f1e05eaaf5655f.tar.gz" \
        --strip-components 1 \
        -C "$SRC_DIR" \
    && cd "$SRC_DIR" \
    && make build

#@follow_tag(ubi8-minimal:8-released)
FROM ubi8-minimal:8.1-409

ENV OPERATOR=/usr/local/bin/hyperconverged-cluster-operator \
    USER_UID=1001 \
    USER_NAME=hyperconverged-cluster-operator \
    CSV_MERGER=/usr/local/bin/csv-merger

RUN microdnf install -y shadow-utils

COPY --from=builder /go/src/github.com/kubevirt/hyperconverged-cluster-operator/_out/hyperconverged-cluster-operator ${OPERATOR}
COPY --from=builder /go/src/github.com/kubevirt/hyperconverged-cluster-operator/build/bin /usr/local/bin
COPY --from=builder /go/src/github.com/kubevirt/hyperconverged-cluster-operator/_out/csv-merger $CSV_MERGER
RUN  /usr/local/bin/user_setup

ENTRYPOINT ["/usr/local/bin/entrypoint"]

USER ${USER_UID}

LABEL com.redhat.component="hyperconverged-cluster-operator-container" \
      name="container-native-virtualization/hyperconverged-cluster-operator" \
      version="v2.3.0" \
      release="61" \
      upstream-version="v0.4.0-104-gb88799c" \
      upstream-vcs-ref="b88799c8bb4f414b65949497d2f1e05eaaf5655f" \
      upstream-vcs-type="git" \
      summary="CNV HyperConverged Cluster Operator" \
      io.openshift.expose-services="" \
      io.openshift.tags="cnv,kubevirt,operator" \
      io.k8s.display-name="hyperconverged-cluster-operator" \
      maintainer="Ryan Hallisey <rhallise@redhat.com>" \
      description="CNV HyperConverged Cluster Operator"
