# Build the manager binary
FROM openshift/golang-builder@sha256:4820580c3368f320581eb9e32cf97aeec179a86c5749753a14ed76410a293d83 AS builder
ENV __doozer=update BUILD_RELEASE=202202160023.p0.gf69235e.assembly.stream BUILD_VERSION=v4.10.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=10 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.10.0-202202160023.p0.gf69235e.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=f69235e OS_GIT_VERSION=4.10.0-202202160023.p0.gf69235e.assembly.stream-f69235e SOURCE_DATE_EPOCH=1642511410 SOURCE_GIT_COMMIT=f69235e94392c6c9563742957848cf11a43486cf SOURCE_GIT_TAG=f69235e SOURCE_GIT_URL=https://github.com/openshift/special-resource-operator 

WORKDIR /workspace

# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

COPY hack/ hack/
COPY helm-plugins/ helm-plugins/
COPY Makefile.specialresource.mk Makefile.specialresource.mk
COPY Makefile.helm.mk Makefile.helm.mk
COPY Makefile.helper.mk Makefile.helper.mk
COPY Makefile Makefile
COPY scripts/ scripts/

# Copy the go source
COPY vendor/ vendor/
COPY .patches/ .patches/
COPY main.go main.go
COPY api/ api/
COPY cmd/ cmd/
COPY controllers/ controllers/
COPY pkg/ pkg/

RUN ["make", "manager", "helm-plugins/cm-getter/cm-getter"]

FROM openshift/ose-base:v4.10.0.20220216.010142
ENV __doozer=update BUILD_RELEASE=202202160023.p0.gf69235e.assembly.stream BUILD_VERSION=v4.10.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=10 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.10.0-202202160023.p0.gf69235e.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=f69235e OS_GIT_VERSION=4.10.0-202202160023.p0.gf69235e.assembly.stream-f69235e SOURCE_DATE_EPOCH=1642511410 SOURCE_GIT_COMMIT=f69235e94392c6c9563742957848cf11a43486cf SOURCE_GIT_TAG=f69235e SOURCE_GIT_URL=https://github.com/openshift/special-resource-operator 

COPY helm-plugins/ helm-plugins/

WORKDIR /

ENV HELM_PLUGINS /opt/helm-plugins

COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/helm-plugins ${HELM_PLUGINS}

COPY charts/ /charts/

RUN useradd  -r -u 499 nonroot
RUN getent group nonroot || groupadd -o -g 499 nonroot

ENTRYPOINT ["/manager"]

LABEL \
        io.k8s.display-name="OpenShift Special Resource Operator" \
        io.k8s.description="This is a component of OpenShift and manages the lifecycle of out-of-tree drivers with enablement stack." \
        name="openshift/ose-special-resource-rhel8-operator" \
        com.redhat.component="special-resource-operator-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Special Resource Operator" \
        release="202202160023.p0.gf69235e.assembly.stream" \
        io.openshift.build.commit.id="f69235e94392c6c9563742957848cf11a43486cf" \
        io.openshift.build.source-location="https://github.com/openshift/special-resource-operator" \
        io.openshift.build.commit.url="https://github.com/openshift/special-resource-operator/commit/f69235e94392c6c9563742957848cf11a43486cf" \
        version="v4.10.0"

