FROM openshift/golang-builder:rhel_8_golang_1.15 AS builder
ENV __doozer=update BUILD_RELEASE=202104030128.p0 BUILD_VERSION=v4.7.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=7 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.7.0-202104030128.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=fce8a7d OS_GIT_VERSION=4.7.0-202104030128.p0-fce8a7d SOURCE_DATE_EPOCH=1602504169 SOURCE_GIT_COMMIT=fce8a7d1da589512502926f2d093f0c70ea895dd SOURCE_GIT_TAG=cluster-autoscaler-0.5.1-463-gfce8a7d1 SOURCE_GIT_URL=https://github.com/openshift/leader-elector 

ADD election /go/src/k8s.io/contrib/election
RUN cd /go/src/k8s.io/contrib/election \
 && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' -o leader-elector example/main.go

# Regular image
FROM openshift/ose-base:v4.7.0.20210403.020833
ENV __doozer=update BUILD_RELEASE=202104030128.p0 BUILD_VERSION=v4.7.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=7 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.7.0-202104030128.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=fce8a7d OS_GIT_VERSION=4.7.0-202104030128.p0-fce8a7d SOURCE_DATE_EPOCH=1602504169 SOURCE_GIT_COMMIT=fce8a7d1da589512502926f2d093f0c70ea895dd SOURCE_GIT_TAG=cluster-autoscaler-0.5.1-463-gfce8a7d1 SOURCE_GIT_URL=https://github.com/openshift/leader-elector 

COPY --from=builder /go/src/k8s.io/contrib/election/leader-elector /usr/bin/

USER 1001

ENTRYPOINT [ "leader-elector", "--id=$(hostname)" ]

LABEL \
        io.k8s.description="This is a component of OpenShift Container Platform and provides a leader-elector sidecar container." \
        com.redhat.component="ose-leader-elector-container" \
        maintainer="Michal Dulko <mdulko@redhat.com>" \
        name="openshift/ose-leader-elector" \
        summary="This image provides leader election functionality and can be used as a sidecar container." \
        io.k8s.display-name="leader-elector" \
        version="v4.7.0" \
        io.openshift.tags="openshift" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Networking" \
        io.openshift.maintainer.subcomponent="kuryr" \
        release="202104030128.p0" \
        io.openshift.build.commit.id="fce8a7d1da589512502926f2d093f0c70ea895dd" \
        io.openshift.build.source-location="https://github.com/openshift/leader-elector" \
        io.openshift.build.commit.url="https://github.com/openshift/leader-elector/commit/fce8a7d1da589512502926f2d093f0c70ea895dd"

