FROM openshift/golang-builder:rhel_8_golang_1.16 AS builder
ENV __doozer=update BUILD_RELEASE=202111020858.p0.git.0d83e9b.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202111020858.p0.git.0d83e9b.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=0d83e9b OS_GIT_VERSION=4.9.0-202111020858.p0.git.0d83e9b.assembly.stream-0d83e9b SOURCE_DATE_EPOCH=1628336552 SOURCE_GIT_COMMIT=0d83e9b1045b9d864892a8f5fd975711b0a810b8 SOURCE_GIT_TAG=0d83e9b1 SOURCE_GIT_URL=https://github.com/openshift/cloud-credential-operator 
WORKDIR /go/src/github.com/openshift/cloud-credential-operator
COPY . .
ENV GO_PACKAGE github.com/openshift/cloud-credential-operator
RUN go build -ldflags "-X $GO_PACKAGE/pkg/version.versionFromGit=$(git describe --long --tags --abbrev=7 --match 'v[0-9]*')" ./cmd/cloud-credential-operator
RUN go build -ldflags "-X $GO_PACKAGE/pkg/version.versionFromGit=$(git describe --long --tags --abbrev=7 --match 'v[0-9]*')" ./cmd/ccoctl

FROM openshift/ose-base:v4.9.0.20211102.090836
ENV __doozer=update BUILD_RELEASE=202111020858.p0.git.0d83e9b.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202111020858.p0.git.0d83e9b.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=0d83e9b OS_GIT_VERSION=4.9.0-202111020858.p0.git.0d83e9b.assembly.stream-0d83e9b SOURCE_DATE_EPOCH=1628336552 SOURCE_GIT_COMMIT=0d83e9b1045b9d864892a8f5fd975711b0a810b8 SOURCE_GIT_TAG=0d83e9b1 SOURCE_GIT_URL=https://github.com/openshift/cloud-credential-operator 
COPY --from=builder /go/src/github.com/openshift/cloud-credential-operator/cloud-credential-operator /usr/bin/
COPY --from=builder /go/src/github.com/openshift/cloud-credential-operator/ccoctl /usr/bin/
COPY manifests /manifests
# Update perms so we can copy updated CA if needed
RUN chmod -R g+w /etc/pki/ca-trust/extracted/pem/
# TODO make path explicit here to remove need for ENTRYPOINT
# https://github.com/openshift/installer/blob/a8ddf6619794416c4600a827c2d9284724d382d8/data/data/bootstrap/files/usr/local/bin/bootkube.sh.template#L347
ENTRYPOINT [ "/usr/bin/cloud-credential-operator" ]

LABEL \
        io.openshift.release.operator="true" \
        name="openshift/ose-cloud-credential-operator" \
        com.redhat.component="ose-cloud-credential-operator-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Cloud Credential Operator" \
        release="202111020858.p0.git.0d83e9b.assembly.stream" \
        io.openshift.build.commit.id="0d83e9b1045b9d864892a8f5fd975711b0a810b8" \
        io.openshift.build.source-location="https://github.com/openshift/cloud-credential-operator" \
        io.openshift.build.commit.url="https://github.com/openshift/cloud-credential-operator/commit/0d83e9b1045b9d864892a8f5fd975711b0a810b8" \
        version="v4.9.0"

