Bootstrap: docker
From: centos:8

%help 
# in progress
This is a singularity container packing a python 3.9 (only version) environment with all the packages necessary to execute all the python scripts present in the version 2.10.0 of the gad pipeline.
Python 3.9 is the latest available version in CentOS 8 used for this build.
Authors : valentin.vautrot@u-bourgogne.fr
Creation date : 2023-09-13

%setup
SINGULARITY_ROOTFS=$APPTAINER_ROOTFS
mkdir ${SINGULARITY_ROOTFS}/data

%files
# import custom python packages from local machine
/home/valentinv/Documents/GitLab/gadpipeline/common/GeneralTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/LabkeyTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/InterTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/VcfTools.py /data/
/home/valentinv/Documents/GitLab/gadpipeline/common/CnvTools.py /data/

%post
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

dnf install -y epel-release
dnf update -y --exclude=filesystem
# filesystem packages updates poses problems by tempering with /proc, which is supposed to be owned by root, but is not in the .sif image

dnf remove -y python3 && dnf autoremove
# by safety but useless, "python3" not found. The python3 present in /usr/bin in final image is created with python3.9 install, so it is only a dependency ? python3 --version is 3.9.6 alright.
dnf install -y python39

# install non-pip python packages
mv /data/GeneralTools.py /usr/lib/python3.9/site-packages/
mv /data/LabkeyTools.py /usr/lib/python3.9/site-packages/
# import of LabkeyTools.py in python3 causes error (TabError - indentation). Probably compatibility problem with python2
mv /data/InterTools.py /usr/lib/python3.9/site-packages/
mv /data/VcfTools.py /usr/lib/python3.9/site-packages/
mv /data/CnvTools.py /usr/lib/python3.9/site-packages/
rmdir /data/

# install python pip packages
pip3.9 install -t /usr/lib/python3.9/site-packages/ labkey
pip3.9 install -t /usr/lib/python3.9/site-packages/ numpy
pip3.9 install -t /usr/lib/python3.9/site-packages/ matplotlib