# This Containerfile is used by openshift-ci to build the image, and push it to
# quay.io/ocs-dev/ceph-csi
#
# This image is based on the latest stable Ceph version, which uses CentOS.
#
# Note that other tests run on the latest Fedora release. That makes the binary
# that gets build not necessary compatible with the Ceph version on other
# distributions. Hence the need to rebuild the executable on the OS that will
# be used as deployment image.
#
# Ideally we use a base container that is very closely like the Red Hat Ceph
# Storage (RHCS) product. Unfortunately those container images are not publicly
# available, so we will use the latest Ceph version that is available. If we
# settle on a particular Ceph version, we might be missing out on backports
# that the RHCS product contains (and compiling might fail).

FROM docker.io/ceph/daemon-base:latest AS builder

ENV GOPATH=/go

# install dependencies
RUN dnf -y install \
        git \
        golang \
        make \
        librados-devel \
        librbd-devel \
    && dnf -y update \
    && dnf clean all \
    && true

# compile and link the executable
COPY . /go/src/github.com/ceph/ceph-csi
RUN cd /go/src/github.com/ceph/ceph-csi && make

# final container to use in deployments
FROM docker.io/ceph/daemon-base:latest

COPY --from=builder /go/src/github.com/ceph/ceph-csi/_output/cephcsi /usr/local/bin/cephcsi

RUN chmod +x /usr/local/bin/cephcsi

ENTRYPOINT ["/usr/local/bin/cephcsi"]