Skip to content

Commit

Permalink
Merge branch 'main' into refactoring/#258-Used_a_non-root_user_to_run…
Browse files Browse the repository at this point in the history
…_Jupyter_in_the_Docker_Image_ai-lab
  • Loading branch information
ckunki committed Feb 28, 2024
2 parents 427696b + 4884413 commit 3467495
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
dist
__pycache__/
/TAGS
.vagrant
44 changes: 44 additions & 0 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions vagrant/provisioning/dns.sh
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions vagrant/provisioning/install.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions vagrant/provisioning/install_poetry.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3467495

Please sign in to comment.