Build Singularity container using GitLab CI

I want to build a singularity image in GitLab CI. Unfortunately, the official containers fail with:

Running with gitlab-runner 13.5.0 (ece86343) on gitlab-ci d6913e69
Preparing the "docker" executor
Using Docker executor with image ...
Pulling docker image ...
Using docker image sha256:46d3827bfb2f5088e2960dd7103986adf90f2e5b4cbea9eeb0b0eacfe10e3420 for with digest[email protected]:def886335e36f47854c121be0ce0c70b2ff06d9381fe8b3d1894fee689615624 ...
Preparing environment
Running on runner-d6913e69-project-2906-concurrent-0 via <gitlab.url>...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in <repo-path>
Checking out 708cc829 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
Error: unknown command "sh" for "singularity"

immediately at the beginning, when using a job like this:

  stage: singularity
    - build reproduction/pipeline/semrepro-singularity/semrepro-singularity.sif reproduction/pipeline/semrepro-singularity/semrepro-singularity.def
      - reproduction/pipeline/semrepro-singularity/semrepro-singularity.def
      - reproduction/pipeline/semrepro-singularity/assets/mirrorlist
      - .gitlab/ci/build-semrepo-singularity.yml
      - reproduction/pipeline/semrepro-singularity/semrepro-singularity.sif
    expire_in: 1 hour
  interruptible: true

For me, it seems like GitLab is trying to use a shell that doesn’t exist? How are they supposed to work? In the official example they’re using a special version of the docker image called -gitlab, but that unfortunately isn’t available anymore. Any ideas? I can’t imagine it isn’t possible to build singularity containers within CI? Thanks a lot in advance!

Source: Docker Questions