Create a gist now

Instantly share code, notes, and snippets.

@mej /Vagrantfile
Last active Apr 12, 2018

What would you like to do?
Vagrantfile for Charliecloud VM
# -*- mode: ruby -*-
# vi: set ft=ruby :
#### Check https://goo.gl/9N7e3S for the latest version of this gist!
# (DEPRECATED) Ensure that the vagrant-reload plugin is installed before proceeding:
# $ vagrant plugin install vagrant-reload
#Vagrant.require_plugin "vagrant-reload"
Vagrant.configure("2") do |config|
# https://docs.vagrantup.com.
config.vm.box = "centos/7"
# config.vm.box_check_update = true
config.vm.network "forwarded_port", guest: 8888, host: 8888, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 6006, host: 6006, host_ip: "127.0.0.1"
# config.vm.synced_folder "../data", "/vagrant_data"
#
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "1024"
end
config.vm.provision "bootstrap", type: "shell", privileged: true, inline: <<-SHELL
yum makecache fast
yum -y upgrade
yum -y install git gcc make binutils yum-utils device-mapper-persistent-data lvm2 screen wget curl
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install docker-ce.x86_64
systemctl enable docker && systemctl start docker
echo 1885 > /proc/sys/user/max_user_namespaces
grubby --args="user_namespace.enable=1 namespace.unpriv_enable=1 user.max_user_namespaces=32767" --update-kernel=ALL
echo "user.max_user_namespaces = 32767" > /etc/sysctl.d/51-userns.conf
SHELL
# This will reload the VM during provisioning. Requires the "vagrant-reload" plugin.
config.vm.provision :reload
config.vm.provision "charliecloud-install", type: "shell", privileged: false, inline: <<-SHELL
git clone https://github.com/mej/charliecloud
cd charliecloud
git checkout --track origin/fix/rhel7-build
make PREFIX=/usr/local all get-bats
: PATH=$PATH:$PWD/test/bats/bin make -C test test-build CH_TEST_TARDIR=/var/tmp/cctar CH_TEST_IMGDIR=/var/tmp/ccimg CH_TEST_PERMDIRS=skip
sudo make PREFIX=/usr/local install
SHELL
config.vm.provision "ctr-build", type: "shell", privileged: false, inline: <<-SHELL
export PATH=$PATH:/usr/local/bin
cd charliecloud
(cd test && sudo docker build -t debian9 -f Dockerfile.debian9 . && sudo docker build -t openmpi -f Dockerfile.openmpi .)
for EX in examples/serial/hello examples/mpi/mpihello examples/mpi/mpibench examples/mpi/lammps examples/other/spark ; do
echo Building Docker container $(basename $EX) in $EX
(cd $EX && ch-build -t $(basename $EX) ~/charliecloud)
done
sudo docker pull tensorflow/tensorflow
SHELL
config.vm.provision "ctr-install", type: "shell", privileged: false, inline: <<-SHELL
export PATH=$PATH:/usr/local/bin CTRDIR=/var/tmp
for EX in hello mpihello mpibench lammps spark ; do
echo "Converting Docker container to Charliecloud: $EX -> $CTRDIR/$EX"
ch-docker2tar $EX $CTRDIR
ch-tar2dir $CTRDIR/$EX.tar.gz $CTRDIR
done
echo "Converting Docker container to Charliecloud: tensorflow/tensorflow -> $CTRDIR/tensorflow"
ch-docker2tar tensorflow/tensorflow $CTRDIR
ch-tar2dir $CTRDIR/tensorflow.tensorflow.tar.gz $CTRDIR
mv $CTRDIR/tensorflow.tensorflow $CTRDIR/tensorflow
SHELL
config.vm.provision "charliecloud-test", type: "shell", privileged: false, inline: <<-SHELL
export PATH=$PATH:/usr/local/bin CTRDIR=/var/tmp
ch-run $CTRDIR/hello -- cat /etc/os-release
ch-run $CTRDIR/mpihello -- mpirun -np 4 /hello/hello
ch-run -b /run:/run $CTRDIR/tensorflow -- ./run_jupyter.sh </dev/null &
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment