BootStrap: docker
From: centos:8

%post
        dnf -y install epel-release dnf-utils
        dnf config-manager --set-enabled powertools
        dnf -y update
        dnf -y install vim-enhanced git file make cmake patch which file ninja-build \
               ccache gcc-c++ gcc-gfortran clang libomp-devel gdb valgrind libubsan libasan libtsan \
               eigen3-devel openblas-devel libpng-devel libjpeg-devel platform-python-devel \
               openmpi-devel mpich-devel fftw-devel voro++-devel gsl-devel hdf5-devel \
               netcdf-devel netcdf-cxx-devel netcdf-mpich-devel netcdf-openmpi-devel \
               enchant python3-virtualenv doxygen diffutils latexmk readline-devel \
               texlive-latex-fonts texlive-pslatex texlive-collection-latexrecommended \
               texlive-latex texlive-latexconfig doxygen-latex texlive-collection-latex \
               texlive-latex-bin texlive-lualatex-math texlive-fncychap texlive-tabulary \
               texlive-framed texlive-wrapfig texlive-upquote texlive-capt-of \
               texlive-needspace texlive-titlesec texlive-anysize texlive-dvipng \
               blas-devel lapack-devel libyaml-devel openkim-models kim-api-devel \
               zstd libzstd-devel
        dnf clean all

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi

        # manually install Plumed
        mkdir plumed
        cd plumed
        version=2.7.2
        curl -L -o plumed.tar.gz https://github.com/plumed/plumed2/releases/download/v${version}/plumed-src-${version}.tgz
        tar -xzf plumed.tar.gz
        cd plumed-${version}
        ./configure --disable-doc --prefix=/usr
        make
        make install
        # fix up installation for CentOS and Fedora
        mv -v /usr/lib64/pkgconfig/plumed* /usr/share/pkgconfig/
        cd ../../
        rm -rvf plumed

        # create missing readline pkgconfig file
        cat > /usr/lib64/pkgconfig/readline.pc <<EOF
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib64
includedir=/usr/include

Name: Readline
Description: GNU Readline library for command line editing
URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html
Version: 7.0
Requires.private: ncurses
Libs: -L\${libdir} -lreadline
Cflags: -I\${includedir}/readline
EOF
        # set custom prompt indicating the container name
        CUSTOM_PROMPT_ENV=/.singularity.d/env/99-zz_custom_prompt.sh
        cat >$CUSTOM_PROMPT_ENV <<EOF
#!/bin/bash
PS1="[centos8:\u@\h] \W> "
EOF
        chmod 755 $CUSTOM_PROMPT_ENV


%environment
        LC_ALL=C
        export LC_ALL

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi
        # tell OpenMPI to not try using Infiniband
        OMPI_MCA_btl="^openib"
        # do not warn about unused components as this messes up testing
        OMPI_MCA_btl_base_warn_component_unused="0"
        export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

%labels
        Author akohlmey, rbberger
