Skip to content

Commit

Permalink
#17: Added vagrant setup (#106)
Browse files Browse the repository at this point in the history
* Ignored main branch in check_packaging.yaml

Co-authored-by: Muhammet Orazov <[email protected]>
  • Loading branch information
tkilias and morazow authored Jun 6, 2023
1 parent 4e15f8d commit 6a4358f
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/check_packaging.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Check packaging of the python package

on: [push]
on:
push:
branches-ignore:
- main

jobs:
check_packaging:
Expand Down Expand Up @@ -30,3 +33,7 @@ jobs:

- name: Show diff on working copy
run: git diff --cached

- name: Check if packaging changed
run: |
[ -z "$(git status --porcelain=v1 -uno 2>/dev/null)" ]
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ doc/_build
# Luarocks

.luarocks

# vagrant

.vagrant
48 changes: 48 additions & 0 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
home_directory = Dir.home

Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2004"
config.vm.hostname = "advanced-analytics-framework"
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/resize-disk.sh"
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.8 python3.8-venv python3.8-dev build-essential python3-pip
python3.8 -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.8 -
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
11 changes: 11 additions & 0 deletions vagrant/provisioning/resize-disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -euo pipefail

echo ", +" | sudo sfdisk --force -N 3 /dev/vda

# refresh partition tables
sudo partprobe

# fill the new space if needed
sudo resize2fs /dev/vda3

0 comments on commit 6a4358f

Please sign in to comment.