Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save truatpasteurdotfr/c160ffaa4b46a47ad196220194e715f0 to your computer and use it in GitHub Desktop.
Save truatpasteurdotfr/c160ffaa4b46a47ad196220194e715f0 to your computer and use it in GitHub Desktop.
vagrant-virtualbox-singularity-osx.txt
# install vagrant
macmini:vagrant tru$ VERS=1.9.1
macmini:vagrant tru$ curl https://releases.hashicorp.com/vagrant/${VERS}/vagrant_${VERS}.dmg > vagrant_${VERS}.dmg
macmini:vagrant tru$ curl https://releases.hashicorp.com/vagrant/${VERS}/vagrant_${VERS}_SHA256SUMS > vagrant_${VERS}_SHA256SUMS
macmini:vagrant tru$ grep vagrant_${VERS}.dmg vagrant_${VERS}_SHA256SUMS | shasum -a 256 -c && \
macmini:vagrant tru$ hdiutil mount vagrant_${VERS}.dmg && \
macmini:vagrant tru$ sudo installer -pkg /Volumes/Vagrant/Vagrant.pkg -target /
macmini:vagrant tru$ hdiutil unmount /Volumes/Vagrant
# installing VirtualBox
macmini:vagrant tru$ VERSVB=5.1.14
macmini:vagrant tru$ RELVB=112924
macmini:vagrant tru$ curl http://download.virtualbox.org/virtualbox/${VERSVB}/VirtualBox-${VERSVB}-${RELVB}-OSX.dmg > VirtualBox-${VERSVB}-${RELVB}-OSX.dmg
macmini:vagrant tru$ curl https://www.virtualbox.org/download/hashes/${VERSVB}/SHA256SUMS > SHA256SUMS
macmini:vagrant tru$ grep VirtualBox-${VERSVB}-${RELVB}-OSX.dmg SHA256SUMS| shasum -a 256 -c && \
macmini:vagrant tru$ hdiutil mount VirtualBox-${VERSVB}-${RELVB}-OSX.dmg && \
macmini:vagrant tru$ sudo installer -pkg /Volumes/VirtualBox/VirtualBox.pkg -target /
macmini:vagrant tru$ hdiutil unmount /Volumes/VirtualBox
# optionnally install the extension pack (check EULA and licensing) at
# https://www.virtualbox.org/wiki/VirtualBox_PUEL
#
#curl http://download.virtualbox.org/virtualbox/${VERSVB}/Oracle_VM_VirtualBox_Extension_Pack-${VERSVB}-${RELVB}.vbox-extpack > Oracle_VM_VirtualBox_Extension_Pack-${VERSVB}-${RELVB}.vbox-extpack
#grep Oracle_VM_VirtualBox_Extension_Pack-${VERSVB}-${RELVB}.vbox-extpack SHA256SUMS| shasum -a 256 -c
#sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-${VERSVB}-${RELVB}.vbox-extpack
# create a working directory for vagrant
macmini:vagrant tru$ mkdir vagrant
macmini:vagrant tru$ cd vagrant
macmini:vagrant tru$ vagrant init centos/7
macmini:vagrant tru$ vagrant up
macmini:vagrant tru$ vagrant ssh
# inside the vagrant CentOS-7 VM:
[vagrant@localhost ]$ sudo yum -y update
[vagrant@localhost ]$ sudo yum -y install rpm-build gcc wget
# if you want the release version of singularity:
[vagrant@localhost ]$ wget https://github.com/singularityware/singularity/releases/download/2.2.1/singularity-2.2.1.tar.gz && \
[vagrant@localhost ]$ rpmbuild -ta singularity-2.2.1.tar.gz
[vagrant@localhost ]$ sudo rpm -ivh /home/vagrant/rpmbuild/RPMS/x86_64/singularity-2.2.1-0.1.el7.centos.x86_64.rpm
# if you want the development version of singularity
[vagrant@localhost ]$ sudo yum -y install rpm-build gcc wget
[vagrant@localhost ]$ sudo yum -y install git libtool automake autoconf make
[vagrant@localhost ]$ git clone https://github.com/singularityware/singularity.git
[vagrant@localhost ]$ cd singularity
[vagrant@localhost singularity]$ ./autogen.sh
[vagrant@localhost singularity]$ ./configure
[vagrant@localhost singularity]$ make dist
[vagrant@localhost singularity]$ rpmbuild -ta singularity-2.2.99.tar.gz
[vagrant@localhost singularity]$ sudo rpm -Uvh /home/vagrant/rpmbuild/RPMS/x86_64/singularity-2.2.99-0.1.el7.centos.x86_64.rpm
# now *poweroff* to upgrade the kernel and increase the RAM of your initial VM
# (512MB to something larger in order to use /dev/shm to work on your container)
[vagrant@localhost singularity]$ sudo poweroff
macmini:vagrant tru$ vagrant status
Current machine states:
default poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
#modify your Vagrantfile (/dev/shm will be half of the allocated RAM).
## for instance change the amount of RAM to 4096 MB
# before:
....
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
...
# after:
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "4096"
end
# https://www.vagrantup.com/docs/cli/reload.html
# After making any modifications to the Vagrantfile, a reload should be called.
macmini:vagrant tru$ vagrant reload
macmini:vagrant tru$ vagrant ssh
# build your singularity containers
[vagrant@localhost ]$ wget https://raw.githubusercontent.com/singularityware/singularity/master/examples/centos.def
[vagrant@localhost ]$ sed -i -e 's/#UpdateURL/UpdateURL/g' centos.def
[vagrant@localhost ]$ wget https://raw.githubusercontent.com/singularityware/singularity/master/examples/docker.def
[vagrant@localhost ]$ sed -i -e 's/ubuntu:latest/centos:centos7/g' docker.def
[vagrant@localhost ]$ sudo singularity create /dev/shm/centos7-yum.img
[vagrant@localhost ]$ sudo singularity bootstrap /dev/shm/centos7-yum.img centos.def
[vagrant@localhost ]$ sudo singularity create /dev/shm/centos7-docker.img
[vagrant@localhost ]$ sudo singularity bootstrap /dev/shm/centos7-docker.img docker.def
# retrieve the files from the vagrant VM (the content od /dev/shm is lost
# when the machine is powered off, it is still there is the VM is suspended)
# from another shell on your OSX host or after logout from your VM
macmini:vagrant tru$ vagrant ssh-config > ssh-config
macmini:vagrant tru$ scp -F ssh-config default:/dev/shm/* .
# suspend when you are done if you want to keep /dev/shm
macmini:vagrant tru$ vagrant suspend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment