Add custom commands and environment variables in the docker/singularity recipes automatically generated by geniac

Modify the conf/geniac.config file

Within the conf/geniac.config file, there are two scopes which allows the definition of custom commands:

  • params.geniac.containers.cmd.post: to define commands which will be executed at the end of the default commands generated by geniac.

  • params.geniac.containers.cmd.envCustom: to define environment variables which will be set inside the docker and singularity images.

For example, assume that you want to add to custom commands and two custom environment variables for the fastqc tool. Then, using the label of your tool (i.e. fastqc) add the following in the conf/geniac.config file:

params {
  geniac {
    containers {
      cmd {
          post {
              fastqc = ['echo Hello', 'echo \"This is fastqc tool!\"']
          }

          envCustom {
              fastqc = ['FASTQC_VAR0=\"fastqc tool variable0\"', 'FASTQC_VAR1=\"fastqc tool variable1\"']
          }
      }
    }
  }
}

The commands and environment variables are provided as a list.

Singularity

For the singularity recipes, the definition file will be affected as follows:

  • params.geniac.containers.cmd.post will add the command in the %post section.

  • params.geniac.containers.cmd.envCustom: will export the variables in the %environment section.

The file recipes/singularity/fastqc.def which will be generated by geniac will be like this:

Bootstrap: docker
From: 4geniac/almalinux:9.3_conda-py311_23.10.0-1

%labels
    gitUrl ssh://git@gitlab.curie.fr:2222/bioinfo-guidelines/geniac-demo.git
    gitCommit 35099a1c9ff4c1e038c9f67bf20a9750e36b78d3 / devel

%environment
    export R_LIBS_USER="-"
    export R_PROFILE_USER="-"
    export R_ENVIRON_USER="-"
    export PYTHONNOUSERSITE=1
    export PATH=$PATH
    export LC_ALL=en_US.utf-8
    export LANG=en_US.utf-8
    source /opt/etc/bashrc
    export FASTQC_VAR0="fastqc tool variable0"
    export FASTQC_VAR1="fastqc tool variable1"

%post
    dnf install -y fontconfig dejavu*  \
    && dnf clean all \
    && conda create -y -n fastqc_env \
    && conda install -y -c conda-forge -c bioconda -n fastqc_env openjdk=8.0.192=h14c3975_1003 fastqc=0.11.6=2 \
    && mkdir -p /opt/etc \
    && echo -e "#! /bin/bash\n\n# script to activate the conda environment fastqc_env" > ~/.bashrc \
    && conda init bash \
    && echo "conda activate fastqc_env" >> ~/.bashrc \
    && cp ~/.bashrc /opt/etc/bashrc \
    && conda clean -a \
    && echo Hello \
    && echo "This is fastqc tool!"

Docker

For the docker recipes, the Dockerfile will be affected as follows:

  • params.geniac.containers.cmd.post will add the command in the RUN directive.

  • params.geniac.containers.cmd.envCustom: will export the variables in the ENV directive.

The file recipes/docker/fastqc.Dockerfile which will be generated by geniac will be like this:

FROM 4geniac/almalinux:9.3_conda-py311_23.10.0-1

LABEL gitUrl="ssh://git@gitlab.curie.fr:2222/bioinfo-guidelines/geniac-demo.git"
LABEL gitCommit="35099a1c9ff4c1e038c9f67bf20a9750e36b78d3 / devel"

ENV R_LIBS_USER "-"
ENV R_PROFILE_USER "-"
ENV R_ENVIRON_USER "-"
ENV PYTHONNOUSERSITE 1
ENV PATH $PATH
ENV LC_ALL en_US.utf-8
ENV LANG en_US.utf-8
ENV BASH_ENV /opt/etc/bashrc
ENV FASTQC_VAR0 "fastqc tool variable0"
ENV FASTQC_VAR1 "fastqc tool variable1"

RUN dnf install -y fontconfig dejavu*  \
&& dnf clean all \
&& conda create -y -n fastqc_env \
&& conda install -y -c conda-forge -c bioconda -n fastqc_env openjdk=8.0.192=h14c3975_1003 fastqc=0.11.6=2 \
&& conda clean -a \
&& echo Hello \
&& echo "This is fastqc tool!" \
&& echo -e "#! /bin/bash\n\n# script to activate the conda environment fastqc_env" > ~/.bashrc \
&& echo "export PS1='Docker> '" >> ~/.bashrc \
&& conda init bash \
&& echo "conda activate fastqc_env" >> ~/.bashrc \
&& mkdir -p /opt/etc \
&& cp ~/.bashrc /opt/etc/bashrc \