├── .github └── workflows │ └── continuous-integration.yml ├── .gitignore ├── LICENSE.txt ├── README.md └── singularity-r.def /.github/workflows/continuous-integration.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: Build 8 | runs-on: ubuntu-latest 9 | container: 10 | image: quay.io/singularity/singularity:v3.8.3 11 | options: "--privileged --workdir /data" 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Build singularity image... 15 | run: | 16 | singularity build singularity-r.sif singularity-r.def 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | singularity-r.sif 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2018-2022 Jeremy Nicklas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Singularity R 2 | 3 | [![Continuous Integration Status](https://github.com/nickjer/singularity-r/workflows/Continuous%20Integration/badge.svg)](https://github.com/nickjer/singularity-r/actions) 4 | [![GitHub License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT) 5 | 6 | Singularity image for [R]. 7 | 8 | This is still a work in progress. 9 | 10 | ## Build 11 | 12 | You can build a local Singularity image named `singularity-r.sif` with: 13 | 14 | ```sh 15 | sudo singularity build singularity-r.sif singularity-r.def 16 | ``` 17 | 18 | ## Deploy 19 | 20 | Instead of building it yourself you can download the pre-built image from the 21 | [Cloud Library](https://cloud.sylabs.io/library) with: 22 | 23 | ```sh 24 | singularity pull singularity-r.sif library://nickjer/default/singularity-r:4.2.1 25 | ``` 26 | 27 | > **WARNING:** This pre-built image comes with OpenBLAS installed using the 28 | > Debian binary packages. Be sure to run any tests with libraries that leverage 29 | > OpenBLAS in your enviroment. If you notice any odd results it may be best to 30 | > build this image from scratch on the machine you intend to run it on. See 31 | > instructions under the Build section above. 32 | > 33 | > Or alternatively you can mount the locally installed OpenBLAS library into 34 | > the container using... 35 | > 36 | > ```sh 37 | > singularity run \ 38 | > --bind "/path/on/host/to/libopenblas.so:/usr/lib/R/lib/libblas.so.3" \ 39 | > singularity-r.sif 40 | > ``` 41 | 42 | ## Run 43 | 44 | ### R 45 | 46 | The `R` command is launched using the default run command: 47 | 48 | ```sh 49 | singularity run singularity-r.sif 50 | ``` 51 | 52 | or as an explicit app: 53 | 54 | ```sh 55 | singularity run --app R singularity-r.sif 56 | ``` 57 | 58 | Example: 59 | 60 | ```console 61 | $ singularity run --app R singularity-r.sif --version 62 | ... 63 | ``` 64 | 65 | ### Rscript 66 | 67 | The `Rscript` command is launched as an explicit app: 68 | 69 | ```sh 70 | singularity run --app Rscript singularity-r.sif 71 | ``` 72 | 73 | Example: 74 | 75 | ```console 76 | $ singularity run --app Rscript singularity-r.sif --version 77 | ... 78 | ``` 79 | 80 | ## Contributing 81 | 82 | Bug reports and pull requests are welcome on GitHub at 83 | https://github.com/nickjer/singularity-r. 84 | 85 | ## License 86 | 87 | The code is available as open source under the terms of the [MIT License]. 88 | 89 | [R]: https://www.r-project.org/ 90 | [MIT License]: http://opensource.org/licenses/MIT 91 | -------------------------------------------------------------------------------- /singularity-r.def: -------------------------------------------------------------------------------- 1 | BootStrap: docker 2 | From: ubuntu:20.04 3 | 4 | %labels 5 | Maintainer Jeremy Nicklas 6 | R_Version 4.2.1 7 | 8 | %apprun R 9 | exec R "${@}" 10 | 11 | %apprun Rscript 12 | exec Rscript "${@}" 13 | 14 | %runscript 15 | exec R "${@}" 16 | 17 | %post 18 | # Software versions 19 | export R_VERSION=4.2.1 20 | echo "export R_VERSION=${R_VERSION}" >> $SINGULARITY_ENVIRONMENT 21 | 22 | # Get dependencies 23 | apt-get update 24 | apt-get install -y --no-install-recommends \ 25 | locales 26 | 27 | # Configure default locale 28 | echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen 29 | locale-gen en_US.utf8 30 | /usr/sbin/update-locale LANG=en_US.UTF-8 31 | export LC_ALL=en_US.UTF-8 32 | export LANG=en_US.UTF-8 33 | 34 | # Install R 35 | apt-get update 36 | apt-get install -y --no-install-recommends \ 37 | software-properties-common \ 38 | dirmngr \ 39 | wget 40 | wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \ 41 | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 42 | add-apt-repository \ 43 | "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" 44 | apt-get install -y --no-install-recommends \ 45 | r-base=${R_VERSION}* \ 46 | r-base-core=${R_VERSION}* \ 47 | r-base-dev=${R_VERSION}* \ 48 | r-recommended=${R_VERSION}* \ 49 | r-base-html=${R_VERSION}* \ 50 | r-doc-html=${R_VERSION}* \ 51 | libcurl4-openssl-dev \ 52 | libssl-dev \ 53 | libxml2-dev \ 54 | libcairo2-dev \ 55 | libxt-dev \ 56 | libopenblas-dev 57 | 58 | # Add a default CRAN mirror 59 | echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/lib/R/etc/Rprofile.site 60 | 61 | # Add a directory for host R libraries 62 | mkdir -p /library 63 | echo "R_LIBS_SITE=/library:\${R_LIBS_SITE}" >> /usr/lib/R/etc/Renviron.site 64 | 65 | # Clean up 66 | rm -rf /var/lib/apt/lists/* 67 | 68 | %test 69 | 70 | R --quiet -e "stopifnot(getRversion() == '${R_VERSION}')" 71 | --------------------------------------------------------------------------------