Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition file for apptainer #1240

Closed
monique2208 opened this issue May 15, 2024 · 5 comments · Fixed by #1254
Closed

Definition file for apptainer #1240

monique2208 opened this issue May 15, 2024 · 5 comments · Fixed by #1254

Comments

@monique2208
Copy link

We use apptainer. I tried to directly convert the docker image, but this does not work because of the different ways docker and apptainer handle the home directory.

The issue is that home is not available when apptainer builds the container. The octave savepath function tries to write the new paths into the octaverc file in home by default, so it ends in the container root. But this file is not read again when the container runs. I converted the docker file into a definition file, where I specify that the new paths should be saved in a global octaverc file, so that home is not required.

I add it here if anyone is interested. I have done limited testing but I have not had issues so far.

apptainer/singularity definition file
BootStrap: docker
From: bids/base_validator

%post
    apt-get -qq update
    DEBIAN_FRONTEND=noninteractive apt-get --yes --quiet install \
        build-essential \
        software-properties-common \
        apt-utils \
        ca-certificates \
        git \
        curl \
        python3 \
        python3-pip \
        fonts-freefont-otf \
        ghostscript \
        gnuplot-x11 \
        libcurl4-gnutls-dev \
        octave \
        liboctave-dev \
        octave-common \
        octave-io \
        octave-image \
        octave-signal \
        octave-statistics && \
    apt-get clean && \
    rm -rf \
        /tmp/hsperfdata* \
        /var/*/apt/*/partial \
        /var/lib/apt/lists/* \
        /var/log/apt/term*
    
    mkdir /opt/spm12
    curl -fsSL --retry 5 https://github.com/spm/spm12/archive/r7771.tar.gz | tar -xzC /opt/spm12 --strip-components 1 
    curl -fsSL --retry 5 https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch | patch -p0
    make -C /opt/spm12/src PLATFORM=octave distclean
    make -C /opt/spm12/src PLATFORM=octave
    make -C /opt/spm12/src PLATFORM=octave install
    ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12

    mkdir /opt/bidspm
    git clone --recurse-submodules https://github.com/cpp-lln-lab/bidspm.git /opt/bidspm
    pip install --no-cache-dir --upgrade pip && \
    pip3 --no-cache-dir install /opt/bidspm && \
    octave --no-gui --eval "addpath('/opt/spm12/'); savepath ('/usr/share/octave/site/m/startup/octaverc');" && \
    octave --no-gui --eval "addpath('/opt/bidspm/'); savepath('/usr/share/octave/site/m/startup/octaverc'); bidspm(); path"

%runscript
    bidspm "$@"

%help
    BIDSpm container
Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@Remi-Gau
Copy link
Contributor

Remi-Gau commented Jul 1, 2024

Will move this into a PR to be added to the code base: easier to find for others

@Remi-Gau
Copy link
Contributor

Remi-Gau commented Jul 1, 2024

@all-contributors please add @monique2208 for code

Copy link
Contributor

@Remi-Gau

I've put up a pull request to add @monique2208! 🎉

@Remi-Gau
Copy link
Contributor

@monique2208 I may try to actually incorporate this change in the dockerfile recipe directly so that there is only a single container definition for docker and apptainer (easier for maintenance)

if you see that the image you build when pulling from dockerhub with apptainer is giving trouble again, reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants