-
Notifications
You must be signed in to change notification settings - Fork 56
/
Vagrantfile
69 lines (56 loc) · 2.45 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Provides a CATMAID development environment
# required to prevent virtualbox trying to start several servers
# on the same interface
# https://github.com/hashicorp/vagrant/issues/8878#issuecomment-345112810
class VagrantPlugins::ProviderVirtualBox::Action::Network
def dhcp_server_matches_config?(dhcp_server, config)
true
end
end
Vagrant.configure("2") do |config|
# also consider bento/ubuntu-* boxes
config.vm.box = "ubuntu/focal64"
if ENV["CATMAID_VM_DISK"]
# https://askubuntu.com/a/1209925/439260
unless Vagrant.has_plugin?("vagrant-disksize")
raise Vagrant::Errors::VagrantError.new, "vagrant-disksize plugin is missing. Install it using 'vagrant plugin install vagrant-disksize' and rerun 'vagrant up'"
end
config.disksize.size = ENV["CATMAID_VM_DISK"]
# When using bento/ubuntu-18.04 box,
# needed to resize partitions, physical volumes, logical volumes.
# This breaks in ubuntu/bionic64 and more recent bento/ubuntu boxes.
# However, it also may not be necessary.
# See discussion and related PR:
# https://github.com/sprotheroe/vagrant-disksize/issues/37
# config.vm.provision "shell", inline: <<-SHELL
# parted /dev/sda resizepart 1 100%
# pvresize /dev/sda1
# lvresize -rl +100%FREE /dev/mapper/vagrant--vg-root
# SHELL
end
config.vm.provider "virtualbox" do |v|
memory = ENV["CATMAID_VM_RAM_MB"] ? ENV["CATMAID_VM_RAM_MB"].to_i : 2048
v.memory = memory
cpus = ENV["CATMAID_VM_CPUS"] ? ENV["CATMAID_VM_CPUS"].to_i : 2
v.cpus = cpus
end
# source directory
config.vm.synced_folder "./", "/CATMAID"
config.vm.hostname = "catmaid-vm"
config.vm.define "catmaid-vm"
# django dev server
config.vm.network "forwarded_port", guest: 8888, host: 8888, host_ip: "127.0.0.1"
# HTML sphinx-docs with `make serve`
config.vm.network "forwarded_port", guest: 8889, host: 8889, host_ip: "127.0.0.1"
# postgreSQL
config.vm.network "forwarded_port", guest: 5555, host: 5555, host_ip: "127.0.0.1"
config.vm.network "private_network", type: "dhcp"
config.vm.provision :shell, path: "scripts/vagrant/root.sh"
config.vm.provision :shell, privileged: false, path: "scripts/vagrant/user.sh"
begin
tz_name = `timedatectl | grep "Time zone" | awk '{print $3}'`.strip
config.vm.provision :shell, privileged: false, :inline => "echo \"#{tz_name}\" > ~/timezone"
rescue SystemCallError
puts "POSIX shell not available, using default server timezone"
end
end