Skip to content

conversion of Dockerfile to singularity recipes can fail when remote file was redirected #228

@m-jahn

Description

@m-jahn

Expected Behavior

Hi! We use spython to convert Dockerfiles to singularity recipes. Dockerfiles can be automatically created for snakemake workflows using the snakemake --containerize command, but Snakemake primarily uses Singularity/Apptainer, hence the conversion. I noticed now, that the conversion can fail when converting a Docker command like this:

ADD https://github.com/snakemake/snakemake-wrappers/raw/v6.0.0/bio/fastqc/environment.yaml /conda-envs/7cdb9e3180904a671be6b170bf7651d2/environment.yaml

to a singularity recipe:

curl https://github.com/snakemake/snakemake-wrappers/raw/v6.0.0/bio/fastqc/environment.yaml -o /conda-envs/7cdb9e3180904a671be6b170bf7651d2/environment.yaml

The problem is that when the link above redirects, the downloaded file is empty, but it doesn't produce an error message. The building of the apptainer image then fails, because the expected conda env definition (or any other file) is not correctly downloaded.

The correct fix in my opinion would be to translate the curl command as curl -L ... which is the redirect-safe approach.

Steps to Reproduce

Dockerfile:

FROM condaforge/miniforge3:latest
RUN apt-get update && apt-get install -y curl
RUN mkdir -p /conda-envs/myenv
ADD https://github.com/snakemake/snakemake-wrappers/raw/v6.0.0/bio/fastqc/environment.yaml /conda-envs/myenv/environment.yaml

then convert with spython recipe Dockerfile > apptainer.def to:

Bootstrap: docker
From: condaforge/miniforge3:latest
Stage: spython-base

%post
apt-get update && apt-get install -y curl
mkdir -p /conda-envs/myenv
curl https://github.com/snakemake/snakemake-wrappers/raw/v6.0.0/bio/fastqc/environment.yaml -o /conda-envs/myenv/environment.yaml

Context

[provide more detailed introduction to the issue itself . This is for make a reproducible issue.]

  • Operating System: Ubuntu 24.04.3 LTS
  • singularity version: apptainer version 1.4.4
  • spython version: 0.3.14
  • python version: 3.13.9

Failure Logs

+ conda env create --prefix /conda-envs/myenv --file /conda-envs/myenv/environment.yaml
Retrieving notices: done
ERROR conda.plugins.manager:detect_environment_specifier(598): EnvironmentSpec hook: an error occurred when handling '/conda-envs/myenv/environment.yaml' with plugin 'cep-24'. 'NoneType' object is not iterable

EnvironmentSpecPluginNotDetected: Environment at /conda-envs/7cdb9e3180904a671be6b170bf7651d2/environment.yaml is not able to be detected by any installed environment specifier plugins.

Available plugins: 
    - cep-24
    - environment.yml
    - explicit
    - requirements.txt

Found compatible plugins but they must be explicitly selected.
Request conda to use these plugins by providing
the cli argument `--environment-spec PLUGIN_NAME`:

    - environment.yml

FATAL:   While performing build: while running engine: while running %post section: exit status 1

Possible Fix

see above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions