BootStrap: docker
From: fedora:36

%post
        dnf -y update
        dnf -y install vim-enhanced git file make cmake patch which file Lmod \
               ninja-build clang clang-tools-extra libomp-devel libubsan libasan libtsan \
               diffutils dos2unix findutils rsync python-devel libjpeg-devel libpng-devel \
               ccache gcc-c++ gcc-gfortran gdb valgrind eigen3-devel openblas-devel \
               openmpi-devel mpich-devel fftw-devel voro++-devel gsl-devel hdf5-devel \
               netcdf-devel netcdf-cxx-devel netcdf-mpich-devel netcdf-openmpi-devel \
               readline-devel python3-pyyaml python3-Cython \
               mingw-filesystem-base mingw32-nsis mingw-binutils-generic \
               mingw32-filesystem mingw32-pkg-config \
               mingw64-filesystem mingw64-pkg-config \
               mingw32-crt mingw32-headers mingw32-binutils \
               mingw64-crt mingw64-headers mingw64-binutils \
               mingw32-cpp mingw32-gcc mingw32-gcc-gfortran mingw32-gcc-c++ \
               mingw64-cpp mingw64-gcc mingw64-gcc-gfortran mingw64-gcc-c++ \
               mingw32-libgomp mingw64-libgomp \
               mingw32-winpthreads mingw64-winpthreads \
               mingw32-eigen3 mingw64-eigen3 \
               mingw32-fftw mingw64-fftw \
               mingw32-libjpeg-turbo mingw64-libjpeg-turbo \
               mingw32-libpng mingw64-libpng \
               mingw32-python3 mingw64-python3 \
               mingw32-python3-numpy mingw64-python3-numpy \
               mingw32-python3-pyyaml mingw64-python3-pyyaml \
               mingw32-python3-setuptools mingw64-python3-setuptools \
               mingw32-readline mingw64-readline \
               mingw32-termcap mingw64-termcap \
               mingw32-zlib mingw64-zlib \
               mingw32-zstd mingw64-zstd \
               enchant python3-virtualenv doxygen latexmk \
               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-pict2e \
               texlive-needspace texlive-titlesec texlive-anysize texlive-dvipng texlive-xindy \
               blas-devel lapack-devel libyaml-devel openkim-models kim-api-devel \
               zstd libzstd-devel yaml-cpp-devel
        dnf clean all

        # install NSIS EnVar plugin
        curl -L -o EnVar_plugin.zip https://nsis.sourceforge.io/mediawiki/images/7/7f/EnVar_plugin.zip
        unzip -d /usr/share/nsis EnVar_plugin.zip
        rm EnVar_plugin.zip

        # enable Lmod and load MPI
        source /usr/share/lmod/lmod/init/profile
        module purge
        module load mpi

        # manually install Plumed
        mkdir plumed
        cd plumed
        version=2.8.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 termcap pkgconfig files
        cat > /usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/termcap.pc <<EOF
prefix=/usr/i686-w64-mingw32/sys-root/mingw
exec_prefix=/usr/i686-w64-mingw32/sys-root/mingw
libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib
includedir=/usr/i686-w64-mingw32/sys-root/mingw/include

Name: Termcap
Description: GNU/MinGW terminal feature database
URL: ftp://ftp.gnu.org/gnu/termcap/
Version: 1.3
Libs: -L\${libdir} -ltermcap
Cflags:
EOF
        cat > /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/termcap.pc <<EOF
prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
exec_prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
libdir=/usr/x86_64-w64-mingw32/sys-root/mingw/lib
includedir=/usr/x86_64-w64-mingw32/sys-root/mingw/include

Name: Termcap
Description: GNU/MinGW terminal feature database
URL: ftp://ftp.gnu.org/gnu/termcap/
Version: 1.3
Libs: -L\${libdir} -ltermcap
Cflags:
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="[fedora36:\u@\h] \W> "
EOF
        chmod 755 $CUSTOM_PROMPT_ENV

%environment
        # 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
