FROM openshift/golang-builder:rhel_8_golang_1.15 AS builder
ENV __doozer=update BUILD_RELEASE=202102200141.p0 BUILD_VERSION=v4.6.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=6 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.6.0-202102200141.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=55dc33f6de5fda4b648662f5da127690c884ac25 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+55dc33f OS_GIT_COMMIT=55dc33f OS_GIT_VERSION=4.6.0-202102200141.p0-55dc33f SOURCE_DATE_EPOCH=1613067158 SOURCE_GIT_COMMIT=55dc33f6de5fda4b648662f5da127690c884ac25 SOURCE_GIT_TAG=55dc33f6 SOURCE_GIT_URL=https://github.com/openshift/cluster-logging-operator 
WORKDIR /go/src/github.com/openshift/cluster-logging-operator

# COPY steps are in the reverse order of frequency of change
COPY cmd ./cmd
COPY must-gather ./must-gather
COPY version ./version
COPY scripts ./scripts
COPY files ./files
COPY go.mod .
COPY go.sum .
COPY vendor ./vendor
COPY manifests ./manifests
COPY .bingo .bingo
COPY Makefile ./Makefile
COPY pkg ./pkg

RUN make build

FROM openshift/ose-cli:v4.6.0.20210220.022506 AS origincli
ENV __doozer=update BUILD_RELEASE=202102200141.p0 BUILD_VERSION=v4.6.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=6 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.6.0-202102200141.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=55dc33f6de5fda4b648662f5da127690c884ac25 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+55dc33f OS_GIT_COMMIT=55dc33f OS_GIT_VERSION=4.6.0-202102200141.p0-55dc33f SOURCE_DATE_EPOCH=1613067158 SOURCE_GIT_COMMIT=55dc33f6de5fda4b648662f5da127690c884ac25 SOURCE_GIT_TAG=55dc33f6 SOURCE_GIT_URL=https://github.com/openshift/cluster-logging-operator 

FROM openshift/ose-base:v4.6.0.20210220.022506
ENV __doozer=update BUILD_RELEASE=202102200141.p0 BUILD_VERSION=v4.6.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=6 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.6.0-202102200141.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=55dc33f6de5fda4b648662f5da127690c884ac25 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+55dc33f OS_GIT_COMMIT=55dc33f OS_GIT_VERSION=4.6.0-202102200141.p0-55dc33f SOURCE_DATE_EPOCH=1613067158 SOURCE_GIT_COMMIT=55dc33f6de5fda4b648662f5da127690c884ac25 SOURCE_GIT_TAG=55dc33f6 SOURCE_GIT_URL=https://github.com/openshift/cluster-logging-operator 
RUN INSTALL_PKGS=" \
      openssl \
      file \
      rsync \
      " && \
    yum install -y $INSTALL_PKGS && \
    rpm -V $INSTALL_PKGS && \
    yum clean all && \
    mkdir /tmp/ocp-clo && \
    chmod og+w /tmp/ocp-clo
COPY --from=builder /go/src/github.com/openshift/cluster-logging-operator/bin/cluster-logging-operator /usr/bin/
COPY --from=builder /go/src/github.com/openshift/cluster-logging-operator/scripts/* /usr/bin/scripts/

RUN mkdir -p /usr/share/logging/
COPY --from=builder /go/src/github.com/openshift/cluster-logging-operator/files/ /usr/share/logging/

COPY --from=builder /go/src/github.com/openshift/cluster-logging-operator/manifests /manifests
RUN rm /manifests/art.yaml

COPY --from=origincli /usr/bin/oc /usr/bin/
COPY --from=builder /go/src/github.com/openshift/cluster-logging-operator/must-gather/collection-scripts/* /usr/bin/

# this is required because the operator invokes a script as `bash scripts/cert_generation.sh`
WORKDIR /usr/bin
CMD ["/usr/bin/cluster-logging-operator"]

LABEL \
        io.k8s.display-name="Cluster Logging Operator" \
        io.k8s.description="This is a component of OpenShift Container Platform that manages the lifecycle of the Aggregated logging stack." \
        io.openshift.tags="openshift,logging" \
        com.redhat.delivery.appregistry="False" \
        maintainer="AOS Logging <aos-logging@redhat.com>" \
        License="GPLv2+" \
        name="openshift/ose-cluster-logging-operator" \
        com.redhat.component="cluster-logging-operator-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Logging" \
        release="202102200141.p0" \
        io.openshift.build.commit.id="55dc33f6de5fda4b648662f5da127690c884ac25" \
        io.openshift.build.source-location="https://github.com/openshift/cluster-logging-operator" \
        io.openshift.build.commit.url="https://github.com/openshift/cluster-logging-operator/commit/55dc33f6de5fda4b648662f5da127690c884ac25" \
        version="v4.6.0"

