FROM openshift/golang-builder:rhel_8_golang_1.16 AS builder
ENV __doozer=update BUILD_RELEASE=202111020903.p0.git.5649248.assembly.stream BUILD_VERSION=v4.8.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=8 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.8.0-202111020903.p0.git.5649248.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=5649248e3d41134d2f0af130b5d00bcd588e7d3d KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+5649248 OS_GIT_COMMIT=5649248 OS_GIT_VERSION=4.8.0-202111020903.p0.git.5649248.assembly.stream-5649248 SOURCE_DATE_EPOCH=1633653046 SOURCE_GIT_COMMIT=5649248e3d41134d2f0af130b5d00bcd588e7d3d SOURCE_GIT_TAG=5649248e3 SOURCE_GIT_URL=https://github.com/openshift/operator-framework-olm 

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

WORKDIR /src

COPY . .
RUN make build/registry cross

# copy and build vendored grpc_health_probe
RUN CGO_ENABLED=0 go build -mod=vendor -tags netgo -ldflags "-w" ./vendor/github.com/grpc-ecosystem/grpc-health-probe/...

FROM openshift/ose-base:v4.8.0.20211102.091449
ENV __doozer=update BUILD_RELEASE=202111020903.p0.git.5649248.assembly.stream BUILD_VERSION=v4.8.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=8 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.8.0-202111020903.p0.git.5649248.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=5649248e3d41134d2f0af130b5d00bcd588e7d3d KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=13+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.13.0+5649248 OS_GIT_COMMIT=5649248 OS_GIT_VERSION=4.8.0-202111020903.p0.git.5649248.assembly.stream-5649248 SOURCE_DATE_EPOCH=1633653046 SOURCE_GIT_COMMIT=5649248e3d41134d2f0af130b5d00bcd588e7d3d SOURCE_GIT_TAG=5649248e3 SOURCE_GIT_URL=https://github.com/openshift/operator-framework-olm 

COPY --from=builder /src/bin/* /bin/registry/
COPY --from=builder /src/grpc-health-probe /bin/grpc_health_probe

RUN ln -s /bin/registry/* /bin

RUN mkdir /registry
RUN chgrp -R 0 /registry && \
    chmod -R g+rwx /registry
WORKDIR /registry

USER 1001
EXPOSE 50051

ENTRYPOINT ["/bin/registry-server"]
CMD ["--database", "/bundles.db"]

LABEL \
        io.k8s.display-name="OpenShift Operator Registry" \
        io.k8s.description="This is a component of OpenShift Operator Lifecycle Manager and is the base for operator catalog API containers." \
        maintainer="Odin Team <aos-odin@redhat.com>" \
        summary="Operator Registry runs in a Kubernetes or OpenShift cluster to provide operator catalog data to Operator Lifecycle Manager." \
        name="openshift/ose-operator-registry" \
        com.redhat.component="operator-registry-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="OLM" \
        release="202111020903.p0.git.5649248.assembly.stream" \
        io.openshift.build.commit.id="5649248e3d41134d2f0af130b5d00bcd588e7d3d" \
        io.openshift.build.source-location="https://github.com/openshift/operator-framework-olm" \
        io.openshift.build.commit.url="https://github.com/openshift/operator-framework-olm/commit/5649248e3d41134d2f0af130b5d00bcd588e7d3d" \
        version="v4.8.0"

