FROM openshift/golang-builder:rhel_8_golang_1.16 AS builder
ENV __doozer=update BUILD_RELEASE=202111292253.p0.gb81033d.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-202111292253.p0.gb81033d.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=b81033d OS_GIT_VERSION=4.8.0-202111292253.p0.gb81033d.assembly.stream-b81033d SOURCE_DATE_EPOCH=1638222258 SOURCE_GIT_COMMIT=b81033d29af3654503dc1505b86032a7a7a88dde SOURCE_GIT_TAG=b81033d2 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.8.0-202111041632.p0.git.ad38e11.assembly.stream
ENV __doozer=update BUILD_RELEASE=202111292253.p0.gb81033d.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-202111292253.p0.gb81033d.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=b81033d OS_GIT_VERSION=4.8.0-202111292253.p0.gb81033d.assembly.stream-b81033d SOURCE_DATE_EPOCH=1638222258 SOURCE_GIT_COMMIT=b81033d29af3654503dc1505b86032a7a7a88dde SOURCE_GIT_TAG=b81033d2 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="202111292253.p0.gb81033d.assembly.stream" \
        io.openshift.build.commit.id="b81033d29af3654503dc1505b86032a7a7a88dde" \
        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/b81033d29af3654503dc1505b86032a7a7a88dde" \
        version="v4.8.0"

