diff --git a/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-file.txt b/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-file.txt index 05a980b57..045faf01b 100644 --- a/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-file.txt +++ b/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-file.txt @@ -1,6 +1,10 @@ FROM {{mamba_image}} AS build +USER root COPY --chown=$MAMBA_USER:$MAMBA_USER conda.yml /tmp/conda.yml -RUN (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \ +# expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it +RUN micromamba install -y -n base conda-forge::which \ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \ + && (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \ && cat /tmp/mamba.log \ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -f /tmp/conda.yml)) \ diff --git a/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-packages.txt b/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-packages.txt index b52b9abd9..50b2e1ca1 100644 --- a/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-packages.txt +++ b/src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-packages.txt @@ -1,6 +1,10 @@ FROM {{mamba_image}} AS build +USER root +# expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it RUN \ - (micromamba install -y -n base {{channel_opts}} {{target}} > /tmp/mamba.log 2>&1 \ + micromamba install -y -n base conda-forge::which \ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \ + && (micromamba install -y -n base {{channel_opts}} {{target}} > /tmp/mamba.log 2>&1 \ && cat /tmp/mamba.log \ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base {{channel_opts}} {{target}})) \ diff --git a/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-file.txt b/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-file.txt index a5ab35211..95de21b96 100644 --- a/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-file.txt +++ b/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-file.txt @@ -3,6 +3,9 @@ From: {{mamba_image}} %files {{wave_context_dir}}/conda.yml /scratch/conda.yml %post + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + micromamba install -y -n base conda-forge::which + ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which micromamba install -y -n base -f /scratch/conda.yml > /tmp/mamba.log 2>&1 \ && cat /tmp/mamba.log \ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \ diff --git a/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-packages.txt b/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-packages.txt index 9efdd8ffc..14c49e017 100644 --- a/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-packages.txt +++ b/src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-packages.txt @@ -1,6 +1,9 @@ BootStrap: docker From: {{mamba_image}} %post + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + micromamba install -y -n base conda-forge::which + ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which micromamba install -y -n base {{channel_opts}} {{target}} > /tmp/mamba.log 2>&1 \ && cat /tmp/mamba.log \ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \ diff --git a/src/main/resources/templates/conda-pixi-v1/dockerfile-conda-file.txt b/src/main/resources/templates/conda-pixi-v1/dockerfile-conda-file.txt index 8ccdce3d8..49fac3371 100644 --- a/src/main/resources/templates/conda-pixi-v1/dockerfile-conda-file.txt +++ b/src/main/resources/templates/conda-pixi-v1/dockerfile-conda-file.txt @@ -4,6 +4,7 @@ COPY conda.yml /opt/wave/conda.yml WORKDIR /opt/wave RUN pixi init --import /opt/wave/conda.yml \ + && pixi add conda-forge::which \ {{base_packages}} && pixi shell-hook > /shell-hook.sh \ && echo 'exec "$@"' >> /shell-hook.sh \ diff --git a/src/main/resources/templates/conda-pixi-v1/singularityfile-conda-file.txt b/src/main/resources/templates/conda-pixi-v1/singularityfile-conda-file.txt index d47df3ce3..8c5a3d856 100644 --- a/src/main/resources/templates/conda-pixi-v1/singularityfile-conda-file.txt +++ b/src/main/resources/templates/conda-pixi-v1/singularityfile-conda-file.txt @@ -5,6 +5,7 @@ From: {{pixi_image}} %post mkdir /opt/wave && cd /opt/wave pixi init --import /scratch/conda.yml + pixi add conda-forge::which {{base_packages}} pixi shell-hook > /shell-hook.sh echo ">> CONDA_LOCK_START" diff --git a/src/test/groovy/io/seqera/wave/util/ContainerHelperTest.groovy b/src/test/groovy/io/seqera/wave/util/ContainerHelperTest.groovy index 087669f1c..a00bc93d6 100644 --- a/src/test/groovy/io/seqera/wave/util/ContainerHelperTest.groovy +++ b/src/test/groovy/io/seqera/wave/util/ContainerHelperTest.groovy @@ -634,6 +634,7 @@ class ContainerHelperTest extends Specification { WORKDIR /opt/wave RUN pixi init --import /opt/wave/conda.yml \\ + && pixi add conda-forge::which \\ && pixi add conda-forge::procps-ng \\ && pixi shell-hook > /shell-hook.sh \\ && echo 'exec "$@"' >> /shell-hook.sh \\ @@ -686,6 +687,7 @@ class ContainerHelperTest extends Specification { WORKDIR /opt/wave RUN pixi init --import /opt/wave/conda.yml \\ + && pixi add conda-forge::which \\ && pixi add foo::one bar::two \\ && pixi shell-hook > /shell-hook.sh \\ && echo 'exec "$@"' >> /shell-hook.sh \\ @@ -730,8 +732,12 @@ class ContainerHelperTest extends Specification { then: result =='''\ FROM mambaorg/micromamba:2-amazon2023 AS build + USER root COPY --chown=$MAMBA_USER:$MAMBA_USER conda.yml /tmp/conda.yml - RUN (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + RUN micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -f /tmp/conda.yml)) \\ @@ -768,8 +774,12 @@ class ContainerHelperTest extends Specification { then: result =='''\ FROM mambaorg/micromamba:2-amazon2023 AS build + USER root COPY --chown=$MAMBA_USER:$MAMBA_USER conda.yml /tmp/conda.yml - RUN (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + RUN micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -f /tmp/conda.yml)) \\ @@ -811,8 +821,12 @@ class ContainerHelperTest extends Specification { then: result =='''\ FROM mambaorg/micromamba:2.0.0 AS build + USER root COPY --chown=$MAMBA_USER:$MAMBA_USER conda.yml /tmp/conda.yml - RUN (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + RUN micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -f /tmp/conda.yml)) \\ @@ -848,8 +862,12 @@ class ContainerHelperTest extends Specification { then: result =='''\ FROM mambaorg/micromamba:2-amazon2023 AS build + USER root + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it RUN \\ - (micromamba install -y -n base -c conda-forge -c bioconda -f https://foo.com/lock.yml > /tmp/mamba.log 2>&1 \\ + micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -c conda-forge -c bioconda -f https://foo.com/lock.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -c conda-forge -c bioconda -f https://foo.com/lock.yml)) \\ diff --git a/src/test/groovy/io/seqera/wave/util/TemplateUtilsTest.groovy b/src/test/groovy/io/seqera/wave/util/TemplateUtilsTest.groovy index eb3f3d125..f423a5f90 100644 --- a/src/test/groovy/io/seqera/wave/util/TemplateUtilsTest.groovy +++ b/src/test/groovy/io/seqera/wave/util/TemplateUtilsTest.groovy @@ -358,6 +358,7 @@ class TemplateUtilsTest extends Specification { WORKDIR /opt/wave RUN pixi init --import /opt/wave/conda.yml \\ + && pixi add conda-forge::which \\ && pixi add foo::bar \\ && pixi shell-hook > /shell-hook.sh \\ && echo 'exec "$@"' >> /shell-hook.sh \\ @@ -393,6 +394,7 @@ class TemplateUtilsTest extends Specification { WORKDIR /opt/wave RUN pixi init --import /opt/wave/conda.yml \\ + && pixi add conda-forge::which \\ && pixi add conda-forge::procps-ng \\ && pixi shell-hook > /shell-hook.sh \\ && echo 'exec "$@"' >> /shell-hook.sh \\ @@ -431,6 +433,7 @@ class TemplateUtilsTest extends Specification { WORKDIR /opt/wave RUN pixi init --import /opt/wave/conda.yml \\ + && pixi add conda-forge::which \\ && pixi add conda-forge::procps-ng \\ && pixi shell-hook > /shell-hook.sh \\ && echo 'exec "$@"' >> /shell-hook.sh \\ @@ -482,8 +485,12 @@ class TemplateUtilsTest extends Specification { expect: TemplateUtils.condaFileToDockerFileUsingV2(CONDA_OPTS) == '''\ FROM mambaorg/micromamba:2.1.1 AS build + USER root COPY --chown=$MAMBA_USER:$MAMBA_USER conda.yml /tmp/conda.yml - RUN (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + RUN micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -f /tmp/conda.yml)) \\ @@ -507,8 +514,12 @@ class TemplateUtilsTest extends Specification { expect: TemplateUtils.condaFileToDockerFileUsingV2(new CondaOpts([:])) == '''\ FROM mambaorg/micromamba:1.5.10-noble AS build + USER root COPY --chown=$MAMBA_USER:$MAMBA_USER conda.yml /tmp/conda.yml - RUN (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + RUN micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -f /tmp/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -f /tmp/conda.yml)) \\ @@ -541,8 +552,12 @@ class TemplateUtilsTest extends Specification { expect: TemplateUtils.condaPackagesToDockerFileUsingV2(PACKAGES, CHANNELS, CONDA_OPTS) == '''\ FROM mambaorg/micromamba:2.1.1 AS build + USER root + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it RUN \\ - (micromamba install -y -n base -c conda-forge -c bioconda bwa=0.7.15 salmon=1.1.1 > /tmp/mamba.log 2>&1 \\ + micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -c conda-forge -c bioconda bwa=0.7.15 salmon=1.1.1 > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -c conda-forge -c bioconda bwa=0.7.15 salmon=1.1.1)) \\ @@ -575,8 +590,12 @@ class TemplateUtilsTest extends Specification { expect: TemplateUtils.condaPackagesToDockerFileUsingV2(PACKAGES, CHANNELS, CONDA_OPTS) == '''\ FROM mambaorg/micromamba:2.1.1 AS build + USER root + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it RUN \\ - (micromamba install -y -n base -c conda-forge numpy pandas > /tmp/mamba.log 2>&1 \\ + micromamba install -y -n base conda-forge::which \\ + && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \\ + && (micromamba install -y -n base -c conda-forge numpy pandas > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ && CONDA_OVERRIDE_CUDA="99" micromamba install -y -n base -c conda-forge numpy pandas)) \\ @@ -665,6 +684,7 @@ class TemplateUtilsTest extends Specification { %post mkdir /opt/wave && cd /opt/wave pixi init --import /scratch/conda.yml + pixi add conda-forge::which pixi add conda-forge::procps-ng pixi shell-hook > /shell-hook.sh echo ">> CONDA_LOCK_START" @@ -685,6 +705,7 @@ class TemplateUtilsTest extends Specification { %post mkdir /opt/wave && cd /opt/wave pixi init --import /scratch/conda.yml + pixi add conda-forge::which pixi add conda-forge::procps-ng pixi shell-hook > /shell-hook.sh echo ">> CONDA_LOCK_START" @@ -712,6 +733,7 @@ class TemplateUtilsTest extends Specification { %post mkdir /opt/wave && cd /opt/wave pixi init --import /scratch/conda.yml + pixi add conda-forge::which pixi shell-hook > /shell-hook.sh echo ">> CONDA_LOCK_START" cat /opt/wave/pixi.lock @@ -769,6 +791,9 @@ class TemplateUtilsTest extends Specification { %files {{wave_context_dir}}/conda.yml /scratch/conda.yml %post + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + micromamba install -y -n base conda-forge::which + ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which micromamba install -y -n base -f /scratch/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ @@ -794,6 +819,9 @@ class TemplateUtilsTest extends Specification { %files {{wave_context_dir}}/conda.yml /scratch/conda.yml %post + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + micromamba install -y -n base conda-forge::which + ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which micromamba install -y -n base -f /scratch/conda.yml > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ @@ -825,6 +853,9 @@ class TemplateUtilsTest extends Specification { BootStrap: docker From: mambaorg/micromamba:2.1.1 %post + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + micromamba install -y -n base conda-forge::which + ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which micromamba install -y -n base -c conda-forge -c bioconda bwa=0.7.15 salmon=1.1.1 > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\ @@ -856,6 +887,9 @@ class TemplateUtilsTest extends Specification { BootStrap: docker From: mambaorg/micromamba:2.1.1 %post + # expose `which` at /usr/bin/which for R (bioconda) post-link scripts; the amazon2023 base image lacks it + micromamba install -y -n base conda-forge::which + ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which micromamba install -y -n base -c conda-forge numpy pandas > /tmp/mamba.log 2>&1 \\ && cat /tmp/mamba.log \\ || (cat /tmp/mamba.log >&2 && grep -q __cuda /tmp/mamba.log \\