# Build stage 1

FROM openshift/golang-builder:1.16 AS builder

ENV GOPATH=/go

RUN mkdir -p /go/src/github.com/kubernetes-incubator/
COPY external-storage-glusterblock-provisioner-v5.0.3.tar.gz /go/src/github.com/kubernetes-incubator/
RUN \
    cd /go/src/github.com/kubernetes-incubator && \
    tar -xzf external-storage-glusterblock-provisioner-v5.0.3.tar.gz && \
    rm external-storage-glusterblock-provisioner-v5.0.3.tar.gz && \
    mv external-storage-* /go/src/github.com/kubernetes-incubator/external-storage

WORKDIR /go
ENV GO111MODULE=off
RUN go build ./src/github.com/kubernetes-incubator/external-storage/gluster/block/cmd/glusterblock-provisioner

# Build stage 2
FROM registry.redhat.io/rhel7/rhel
COPY --from=builder /go/glusterblock-provisioner /usr/bin/
ENV ocsVersion="3.11.8"
ENV ocsRelease="1"
ENV rhgsVersion="3.5"
ENV rhelVersion="7.9"

LABEL maintainer="John Mulligan <jmulliga@redhat.com> Nitin Goyal <nigoyal@redhat.com> Prasanna Kalever <pkalever@redhat.com> Raghavendra Talur <rtalur@redhat.com>"
LABEL com.redhat.component="rhgs-gluster-block-prov-container"
LABEL name="rhgs3/rhgs-gluster-block-prov-rhel7"
LABEL release=${ocsRelease}
LABEL version=${ocsVersion}
LABEL summary="This image has a running gluster block volume provisioner service ( RHEL ${rhelVersion} + RHGS ${rhgsVersion})"
LABEL io.k8s.display-name="RHGS Block Volume Provisioner based on RHEL 7"
LABEL io.k8s.description="Red Hat Gluster Storage Block Volume Provisioner Image is based on Red Hat Enterprise Linux Image"
LABEL description="Red Hat Gluster Storage Block Volume Provisioner Image is based on Red Hat Enterprise Linux Image"
LABEL io.openshift.tags="ocs,rhgs3"
LABEL ocs.tags="v${ocsVersion},v3.11"
LABEL rhgs3.tags="v${ocsVersion},v3.11"

RUN yum update -y && yum clean all;
RUN echo "Red Hat Gluster Block Provisioner ${ocsVersion} (Container)" > /etc/redhat-storage-release

ENTRYPOINT ["/usr/bin/glusterblock-provisioner"]
