FROM centos:7
LABEL maintainers="Gorka Eguileor <geguileo@redhat.com>" \
      description="Ember CSI Plugin" \
      version=master

ENV PYTHONUNBUFFERED=true

# We need to upgrade pyasn1 because the package for RDO is not new enough for
# pyasn1_modules, which is used by some of the Google's libraries

RUN yum -y install targetcli iscsi-initiator-utils device-mapper-multipath epel-release lvm2 which && \
    yum -y install python2-pip python-devel gcc openssl-devel pywbem && \
    yum -y install python-rbd ceph-common rbd-nbd git && \
    # Need new setuptools version or we'll get "SyntaxError: '<' operator not allowed in environment markers" when installing Cinder
    pip install 'setuptools>=38.6.0' future && \
    yum -y install xfsprogs e2fsprogs btrfs-progs nmap-ncat && \
    pip install --no-cache-dir 'krest>=1.3.0' 'purestorage>=1.6.0' 'pyxcli>=1.1.5' 'pyOpenSSL>=1.0.0' && \
    # Shallow clone
    git clone --depth=1 'https://github.com/openstack/cinder.git' && \
    # Apply cinderlib patch
    cd cinder && git fetch https://git.openstack.org/openstack/cinder refs/changes/69/620669/19 && git checkout FETCH_HEAD && cd .. && \
    pip install --no-cache-dir cinder/ && \
    rm -rf cinder && \
    yum -y remove git python-devel gcc openssl-devel && \
    yum clean all && \
    rm -rf /var/cache/yum

# Copy Ember-csi from current directory
COPY . /csi

RUN pip install --no-cache-dir /csi/ && \
    rm -rf /csi

# This is the default port, but if we change it via CSI_ENDPOINT then this will
# no longer be relevant.
# For the Master version expose RPDB port to support remote debugging
EXPOSE 50051 4444

# Enable RPDB debugging on this container by default
ENV X_CSI_DEBUG_MODE=rpdb

# Define default command
CMD ["ember-csi"]
