fairagro / M4.4_UC6_ARC

UC6 workflow in ARC proof-of-concept
0 stars 0 forks source link

Do everything with Apptainer (ex-Singularity) #20

Closed hvwaldow closed 2 months ago

JensKrumsieck commented 2 months ago

Apptainer/Singularity has a different format for the specification of a container. A peculiarity of Apptainer is the availabilty of the local working directory and the home directory in the container due to being automagically mounted. However those are not available in the build step. Therefore installation files have to be copied in a %files block.

In a def-File you can specify a runscript or a startscript which are written into the containers root dir. The runscript is executed when calling the run command on the container.

BootStrap: docker
From: rocker/r-ver:4.4

%files 
    install_dssat.sh /install_dssat.sh

%environment
    export DSSAT_CSM=/usr/local/dssat/dscsm048
    export LANG=C.UTF-8
    export LC_ALL=C.UTF-8

%post
    apt-get update
    apt-get install -y \
                        libudunits2-dev \
                        default-jdk \
                        libproj-dev \
                        libgdal-dev \
                        cmake \
                        git
    ./install_dssat.sh /usr/local/dssat
    R -e 'install.packages("devtools")'

%runscript
    Rscript inst/etl_pipeline_example.R

The definition file has been commited to BLs Repo. The pipeline needed some minor changes to work with Apptainer https://github.com/fairagro/uc6_csmTools/commit/d4a0622d3e2396ee2676d6504fa8e7d2c9def941

Apptainer was installed by following the docs: https://apptainer.org/docs/admin/main/installation.html#install-ubuntu-packages