diff --git a/.gitignore b/.gitignore index 9ce84085..0401dedd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist __pycache__/ /TAGS +.vagrant \ No newline at end of file diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile new file mode 100644 index 00000000..c74a6c80 --- /dev/null +++ b/vagrant/Vagrantfile @@ -0,0 +1,44 @@ +home_directory = Dir.home + +Vagrant.configure("2") do |config| + config.vm.box = "generic/ubuntu2204" + config.vm.hostname = "ai-lab" + config.vm.network :forwarded_port, guest: 8888, host: 8888 + config.vm.network :forwarded_port, guest: 6666, host: 6666 + config.vm.synced_folder "#{home_directory}", "/home/vagrant/", type: "rsync", rsync__exclude: "*", rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links", "--include",".gitconfig", "--include",".git-credentials"], rsync__verbose: true + config.vm.synced_folder ".", "/home/vagrant/vagrant", type: "rsync", rsync__exclude: ".git/" + config.vm.synced_folder "..", "/home/vagrant/project", type: "rsync", rsync__exclude: [".build_output", ".conda_env", ".luarocks"], rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"], rsync__verbose: true + + config.vm.provider :libvirt do |v| + v.qemu_use_session = true + v.cpus = 2 + v.memory = 6000 + v.machine_virtual_size = 100 + v.random_hostname = true + v.default_prefix = config.vm.hostname + "_" + end + + config.vm.provider "virtualbox" do |v| + v.memory = 6000 + v.cpus = 2 + end + + config.trigger.before [:provision] do |trigger| + trigger.run = { inline: "vagrant rsync"} + end + + config.vm.provision "shell" do |s| + s.path="provisioning/dns.sh" + end + + config.vm.provision "shell" do |s| + s.path="provisioning/install.sh" + end + + config.vm.provision "shell" do |s| + s.path="provisioning/install_poetry.sh" + s.privileged=false + end + +end + diff --git a/vagrant/provisioning/dns.sh b/vagrant/provisioning/dns.sh new file mode 100644 index 00000000..524c153b --- /dev/null +++ b/vagrant/provisioning/dns.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +sudo sed -i 's/DNS=.*/DNS=8.8.8.8/g' /etc/systemd/resolved.conf +sudo service systemd-resolved restart +sudo rm -f /etc/resolv.conf +sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf + diff --git a/vagrant/provisioning/install.sh b/vagrant/provisioning/install.sh new file mode 100644 index 00000000..a0f6d335 --- /dev/null +++ b/vagrant/provisioning/install.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +apt-get update +apt-get install -y --no-install-recommends software-properties-common python3.10 python3.10-venv python3.10-dev build-essential python3-pip +python3.10 -m pip install virtualenv +curl -L https://get.docker.com/ | bash +gpasswd -a vagrant docker diff --git a/vagrant/provisioning/install_poetry.sh b/vagrant/provisioning/install_poetry.sh new file mode 100644 index 00000000..9b3ffbd0 --- /dev/null +++ b/vagrant/provisioning/install_poetry.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +curl -sSL https://install.python-poetry.org/ | python3.10 - +echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bashrc +echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bash_profile +echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.poetry_path