1 | # -*- mode: ruby -*-
|
2 | # vi: set ft=ruby :
|
3 |
|
4 | # Application definitions
|
5 | app_name = "kettle"
|
6 | app_directory = "/home/vagrant/#{app_name}"
|
7 |
|
8 | # Resource allocation
|
9 | cpus = ENV["VM_CPUS"] || 2
|
10 | ram = ENV["VM_RAM"] || 2048
|
11 |
|
12 | # Node.js
|
13 | nodejs_branch = "8"
|
14 | nodejs_version = "8.11.4"
|
15 |
|
16 | Vagrant.configure(2) do |config|
|
17 |
|
18 | config.vm.box = "inclusivedesign/fedora28"
|
19 | config.vm.hostname = app_name
|
20 |
|
21 | # Port-forwarding
|
22 | config.vm.network "forwarded_port", guest: 9081, host: 9081, protocol: "tcp", auto_correct: true
|
23 |
|
24 | # Shared folders
|
25 | config.vm.synced_folder ".", "#{app_directory}"
|
26 |
|
27 | # Mounts node_modules in /var/tmp to work around issues in the VirtualBox shared folders
|
28 | #
|
29 | # Set SKIP_NODE_MODULES_BIND_MOUNT to "1" to skip this and have the directory shared
|
30 | # between host and VM
|
31 | if ENV["SKIP_NODE_MODULES_BIND_MOUNT"] != "1"
|
32 | config.vm.provision "shell", run: "always", inline: <<-SHELL
|
33 | mkdir -p /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
|
34 | chown vagrant:vagrant -R /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
|
35 | mount -o bind /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
|
36 | SHELL
|
37 | end
|
38 |
|
39 | # VirtualBox customizations
|
40 | config.vm.provider :virtualbox do |vm|
|
41 | vm.customize ["modifyvm", :id, "--memory", ram]
|
42 | vm.customize ["modifyvm", :id, "--cpus", cpus]
|
43 | vm.customize ["modifyvm", :id, "--vram", "256"]
|
44 | vm.customize ["modifyvm", :id, "--accelerate3d", "off"]
|
45 | vm.customize ["modifyvm", :id, "--audio", "null", "--audiocontroller", "ac97"]
|
46 | vm.customize ["modifyvm", :id, "--ioapic", "on"]
|
47 | vm.customize ["setextradata", "global", "GUI/SuppressMessages", "all"]
|
48 | end
|
49 |
|
50 | # Install system requirements
|
51 | config.vm.provision "shell", inline: <<-SHELL
|
52 | dnf install -y --disablerepo='*' https://rpm.nodesource.com/pub_#{nodejs_branch}.x/fc/28/x86_64/nodesource-release-fc28-1.noarch.rpm
|
53 | dnf install -y gcc-c++ nodejs-#{nodejs_version}
|
54 | echo "cd #{app_directory}" >> /home/vagrant/.bashrc
|
55 | SHELL
|
56 |
|
57 | # Build application
|
58 | config.vm.provision "shell", privileged: false, inline: <<-SHELL
|
59 | npm install
|
60 | SHELL
|
61 |
|
62 | end
|