FROM opensuse/leap:15.4

RUN zypper in -y cmake curl eigen3-devel gcc gcc-c++ gcc-fortran gcc11 gcc11-c++ gcc11-fortran git gzip libxml2-devel make mpich-devel python tar which && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-7 && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-11

WORKDIR /tmp

RUN zypper ar https://yum.repos.intel.com/oneapi oneAPI && \
    zypper --gpg-auto-import-keys ref && \
    zypper in -y intel-oneapi-mkl-devel
ENV MKLROOT "/opt/intel/oneapi/mkl/latest"
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}${MKLROOT}/lib/intel64"

# mpi-selector is useless for docker since profile.d is not sourced
#RUN mpi-selector --system --set mpich
ENV PATH "${PATH}:/usr/lib64/mpi/gcc/mpich/bin"
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}/usr/lib64/mpi/gcc/mpich/lib64"

RUN curl -LsO https://github.com/GlobalArrays/ga/releases/download/v5.8.1/ga-5.8.1.tar.gz && \
    tar -xzf ga-5.8.1.tar.gz && cd ga-5.8.1 && \
    ./configure --prefix=/usr --with-sockets MPICC=mpicc MPICXX=mpicxx --disable-f77 --without-blas --without-lapack --without-scalapack && \
    make && make install && \
    cd /tmp && rm -rf ga-5.8.1.tar.gz ga-5.8.1