BootStrap: docker
From: ubuntu:22.04

%labels
    Author scemama@irsamc.ups-tlse.fr

%help
    Container for running CHAMP.

%environment
    export LANG="C"
    export LANGUAGE=$LANG
    export LC_ALL=$LANG
    export OMP_NUM_THREADS=1

%setup
    mkdir -p ${APPTAINER_ROOTFS}/opt/install
    cp environment.sh  ${APPTAINER_ROOTFS}/opt/
    cp champ.def \
       ../lib/setup_image.sh           \
       ../lib/install_champ.sh         \
       ../lib/install_qmckl.sh         \
       ../lib/install_trexio.sh        \
       ../lib/install_trexio_python.sh \
       ../lib/install_oneapi.sh        \
       ../lib/cleanup_oneapi.sh        \
       ${APPTAINER_ROOTFS}/opt/install

%post
    cd /opt/install
    ./setup_image.sh
    ./install_oneapi.sh
    ./install_trexio.sh
    ./install_trexio_python.sh
    ./install_qmckl.sh
    ./install_champ.sh

    ./cleanup_oneapi.sh

    apt install -y bash vim emacs-nox
    apt autoremove -y
    apt purge -y --auto-remove
    rm -rf /var/lib/apt/lists/*

    echo source /opt/environment.sh >> /etc/bash.bashrc

%runscript
    exec /bin/bash $@

%test
    ls /opt/champ/bin/vmc.mov1 || exit 1
    ls /opt/champ/bin/dmc.mov1 || exit 1

