Recipe on how to create a singularity image file.
- Linux OS and singularity installed.
Use Ubuntu 18.04 as a base to customize:
sudo singularity build --sandbox ubuntu_remix_vx.y.z/ library://ubuntu:18.04
Note: replace the suffix _vx.y.z
to wathever you need.
sudo singularity exec --writable ubuntu_remix_vx.y.z /bin/bash
Update the base system, install vim
(or nano
) to configure the system repository list:
apt update
apt upgrade
apt install vim
Edit the /etc/apt/sources.list
:
vim /etc/apt/sources.list
It should contain:
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic universe
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
Perform a system upgrade:
apt update
apt upgrade
apt install locales locales-all
dpkg-reconfigure locales
Note: choose the locales 378 e 158 (i.e., 378. pt_BR.UTF-8 UTF-8, 158. en_US.UTF-8 UTF-8)
Note: default will be 158
or en_US.UTF-8
And run:
locale-gen
At this point, your requirements may be different. Install everything you need at this point.
apt install vim-gtk
apt install build-essential
apt install gdb gdb-doc
apt install cgdb
apt install cmake ksh csh tcsh automake autoconf autoconf-archive libtool pkg-config
apt install libssl-dev uuid-dev libgpgme11-dev squashfs-tools
apt install xauth
apt install rsync wget
apt install zip p7zip-full
apt install subversion git
apt install gcc-4.8 g++-4.8 gfortran-4.8
apt install gcc-5 g++-5 gfortran-5
apt install gcc-6 g++-6 gfortran-6
apt install gcc-7 g++-7 gfortran-7
apt install gcc-8 g++-8 gfortran-8
apt install mpich libstdc++-6-dev manpages-dev
apt install libhugetlbfs0 libhugetlbfs-dev libblas3 liblapack3
apt install grads cdo nco ncl-ncarg gnuplot
apt install python3 curl htop ncftp sshfs sshpass
apt install netcdf-bin libnetcdf-c++4 libnetcdf-dev libnetcdf13 libnetcdff6 ncview
apt install gdal-bin gdal-data
apt install cdftools hdf5-tools
apt install glueviz libjpeg8 imagemagick
apt install pandoc
apt install doxygen
apt install emacs
apt install mpi-default-dev
cd /usr/bin
ln -s make gmake
Note: only needed if you use MPI.
Create a symlink to the libmpi_mpifh.so
:
cd /usr/lib/x86_64-linux-gnu
ln -s libmpi_mpifh.so.20 libmpi_mpifh.so.40
And run:
ldconfig
apt install mlocate
updatedb
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --remove-all gfortran
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 30
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 40
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 30
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 40
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 50
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.8 10
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-5 20
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-6 30
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-7 40
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-8 50
update-alternatives --config gcc
update-alternatives --config g++
update-alternatives --config gfortran
apt install default-jre default-jdk openjdk-8-jdk
update-alternatives --config java
Choose: /usr/lib/jvm/java-11-openjdk-amd64/bin/java
update-alternatives --config javac
Choose: /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
- Reference: https://www.digitalocean.com/community/tutorials/como-instalar-o-java-com-apt-no-ubuntu-18-04-pt
Perform a system cleanup before the image creation:
apt update
apt upgrade
apt autoremove
apt autoclean
apt clean
exit
This is the part where the singularity container image is created. At this point, you've exited the singularity shell and are at your local machine.
sudo singularity build ubuntu_remix_vx.y.z.sif ubuntu_remix_vx.y.z
If you just want to use the container, you may stop here.
If you don't have a singularity key and follow the screen instructions (it will require a sylabs account - you can use you GitHub or Google account):
singularity keys newpair
Note: take a look at https://sylabs.io/guides/3.0/user-guide/signNverify.html#signing-and-validating-your-own-containers for more information.
If you already have a singularity key (it will require you to login to yout sylabs account):
singularity remote list
singularity remote login SylabsCloud
Note: Go to https://cloud.sylabs.io/auth/tokens and create a new token, copy and paste at the prompt.
singularity keys list
singularity key push <your_key>
singularity sign ubuntu_remix_vx.y.z.sif
singularity push ubuntu_remix_vx.y.z.sif library://your_user_name/default/ubuntu_remix
Note: check your containers at https://cloud.sylabs.io/library/your_user_name to see the correct pull command.
Mine is:
singularity pull library://your_user_name/default/ubuntu_remix:latest
singularity verify ubuntu_remix_vx.y.z.sif
singularity shell -e image_file.sif