FROM openshift/golang-builder:rhel_8_golang_1.15 AS builder
ENV __doozer=update BUILD_RELEASE=202107230321.p0.git.299fb8a 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-202107230321.p0.git.299fb8a SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=299fb8ac987acb680704ba0600473cc7460b3897 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+299fb8a OS_GIT_COMMIT=299fb8a OS_GIT_VERSION=4.6.0-202107230321.p0.git.299fb8a-299fb8a SOURCE_DATE_EPOCH=1624483551 SOURCE_GIT_COMMIT=299fb8ac987acb680704ba0600473cc7460b3897 SOURCE_GIT_TAG=0.16.1-140-g299fb8ac9 SOURCE_GIT_URL=https://github.com/operator-framework/operator-lifecycle-manager 

ENV GO111MODULE auto
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

WORKDIR /build

# copy just enough of the git repo to parse HEAD, used to record version in OLM binaries
COPY .git/HEAD .git/HEAD
COPY .git/refs/heads/. .git/refs/heads
RUN mkdir -p .git/objects

COPY Makefile Makefile
COPY OLM_VERSION OLM_VERSION
COPY pkg pkg
COPY vendor vendor
COPY cmd cmd
COPY util util
COPY test test
COPY go.mod go.mod
COPY go.sum go.sum
RUN CGO_ENABLED=1 make build
RUN make build-util

FROM openshift/ose-base:v4.6.0.20210723.033016
ENV __doozer=update BUILD_RELEASE=202107230321.p0.git.299fb8a 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-202107230321.p0.git.299fb8a SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=299fb8ac987acb680704ba0600473cc7460b3897 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+299fb8a OS_GIT_COMMIT=299fb8a OS_GIT_VERSION=4.6.0-202107230321.p0.git.299fb8a-299fb8a SOURCE_DATE_EPOCH=1624483551 SOURCE_GIT_COMMIT=299fb8ac987acb680704ba0600473cc7460b3897 SOURCE_GIT_TAG=0.16.1-140-g299fb8ac9 SOURCE_GIT_URL=https://github.com/operator-framework/operator-lifecycle-manager 

ADD manifests/ /manifests

# Copy the binary to a standard location where it will run.
COPY --from=builder /build/bin/olm /bin/olm
COPY --from=builder /build/bin/catalog /bin/catalog
COPY --from=builder /build/bin/package-server /bin/package-server
COPY --from=builder /build/bin/cpb /bin/cpb

# This image doesn't need to run as root user.
USER 1001

EXPOSE 8080
EXPOSE 5443

# Apply labels as needed. ART build automation fills in others required for
# shipping, including component NVR (name-version-release) and image name. OSBS
# applies others at build time. So most required labels need not be in the source.
#
# io.k8s.display-name is required and is displayed in certain places in the
# console (someone correct this if that's no longer the case)
#
# io.k8s.description is equivalent to "description" and should be defined per
# image; otherwise the parent image's description is inherited which is
# confusing at best when examining images.
#

LABEL \
        io.openshift.release.operator="true" \
        io.k8s.display-name="OpenShift Container Platform Operator Lifecycle Manager" \
        io.k8s.description="This is a component of OpenShift Container Platform and runs the Operator Lifecycle Manager" \
        maintainer="Odin Team <aos-odin@redhat.com>" \
        License="GPLv2+" \
        vendor="Red Hat" \
        name="openshift/ose-operator-lifecycle-manager" \
        com.redhat.component="operator-lifecycle-manager-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="OLM" \
        release="202107230321.p0.git.299fb8a" \
        io.openshift.build.commit.id="299fb8ac987acb680704ba0600473cc7460b3897" \
        io.openshift.build.source-location="https://github.com/operator-framework/operator-lifecycle-manager" \
        io.openshift.build.commit.url="https://github.com/operator-framework/operator-lifecycle-manager/commit/299fb8ac987acb680704ba0600473cc7460b3897" \
        version="v4.6.0"

