https://github.com/horothesun/singularity-conda-multiple-envs
Singularity containerization of a Conda-based multi-environment bash script.
https://github.com/horothesun/singularity-conda-multiple-envs
conda conda-env conda-environment containerization github-actions github-actions-ci github-actions-ci-cd multi-environment singularity singularity-cloud singularity-container singularity-containers singularity-image singularity-recipe
Last synced: 7 months ago
JSON representation
Singularity containerization of a Conda-based multi-environment bash script.
- Host: GitHub
- URL: https://github.com/horothesun/singularity-conda-multiple-envs
- Owner: horothesun
- Created: 2021-03-10T21:45:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-17T13:33:33.000Z (over 4 years ago)
- Last Synced: 2025-01-04T15:29:36.027Z (9 months ago)
- Topics: conda, conda-env, conda-environment, containerization, github-actions, github-actions-ci, github-actions-ci-cd, multi-environment, singularity, singularity-cloud, singularity-container, singularity-containers, singularity-image, singularity-recipe
- Language: Shell
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Singularity image from Conda multi-environment script
[](https://github.com/horothesun/singularity-conda-multiple-envs/actions/workflows/first-env-ci-linux.yml)
[](https://github.com/horothesun/singularity-conda-multiple-envs/actions/workflows/second-env-ci-linux.yml)
[](https://github.com/horothesun/singularity-conda-multiple-envs/actions/workflows/third-env-ci-linux.yml)[](https://github.com/horothesun/singularity-conda-multiple-envs/actions/workflows/image-build-and-push-linux.yml)
[Singularity](https://singularity.lbl.gov/) containerization of a Conda-based multi-environment `bash` script.
## Requirements
- Conda ([install](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)) for [manual execution](#manual-execution) and
- Docker for [local Singularity image build](#local-singularity-image-build).```bash
# environments creation
./create_conda_envs.sh# run.sh in different environments
conda activate first-env
./run.shconda activate second-env
./run.shconda activate third-env
./run.sh
```## Local Singularity image build
Run `quay.io/singularity` Docker image and access its `bash` with
```bash
docker run \
--interactive --tty --rm --privileged \
--volume $(pwd)/create_conda_envs.sh:/go/create_conda_envs.sh \
--volume $(pwd)/environment-01.yml:/go/environment-01.yml \
--volume $(pwd)/environment-02.yml:/go/environment-02.yml \
--volume $(pwd)/environment-03.yml:/go/environment-03.yml \
--volume $(pwd)/run.sh:/go/run.sh \
--volume $(pwd)/runscript.sh:/go/runscript.sh \
--volume $(pwd)/singularity-image.def:/go/singularity-image.def \
--volume $(pwd)/out:/go/out \
--entrypoint /bin/bash \
quay.io/singularity/singularity:v3.7.2
```then, from within the container's `bash` run
```bash
export IMAGE_FILENAME=/go/out/image.sif# build
singularity build $IMAGE_FILENAME singularity-image.def# inspect
ls -lah $IMAGE_FILENAME
singularity inspect $IMAGE_FILENAME
singularity inspect --deffile $IMAGE_FILENAME# run
singularity run $IMAGE_FILENAME
```## Singularity image signing
Login into [Sylabs.io](https://cloud.sylabs.io/auth) and generate a Singularity Cloud token. Download the token file and save it to `~/.singularity/sylabs-token`.
To generate a new key to sign a Singularity image in a GitHub Action, run
```bash
singularity keys newpair
```and publish the public key on the Singularity Cloud.
Then update the repository secrets as follows
- `SINGULARITY_CLOUD_TOKEN`: run `< ~/.singularity/sylabs-token | pbcopy` (on macOS) and paste the content of your clipboard as value of the secret,
- `SINGULARITY_PGP_PASSPHRASE`: newly generated key's `passphrase` and
- `SINGULARITY_PGP_SECRET_BASE64`: run `< ~/.singularity/sypgp/pgp-secret | base64 | pbcopy` (on macOS) and paste the content of your clipboard as value of the secret.