This repository was archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathVagrantfile
executable file
·93 lines (77 loc) · 3.57 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version "~> 1.8"
require 'yaml'
module OS
def OS.is_windows
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
end
module Config
# Load and override config settings
def Config.load
local_config_dir = 'etc'
config_dist_file = local_config_dir + '/config.yaml.dist'
config_file = local_config_dir + '/config.yaml'
config_data_dist = YAML.load_file(config_dist_file)
config_data = File.exists?(config_file) ? YAML.load_file(config_file) : {}
return config_data_dist.merge!(config_data)
end
end
# Get parameters from config file
config_data = Config.load
magento_host_name = config_data['magento']['host_name']
magento_ip_address = config_data['guest']['ip_address']
forwarded_ssh_port = config_data['guest']['forwarded_ssh_port']
guest_memory = config_data['guest']['memory']
# NFS will be used for *nix and OSX hosts, if not disabled explicitly in config
use_nfs_for_synced_folders = !OS.is_windows && (config_data['guest']['use_nfs'] == 1)
host_magento_dir = Dir.pwd + '/magento2ce'
VAGRANT_API_VERSION = 2
Vagrant.configure(VAGRANT_API_VERSION) do |config|
config.vm.box = "paliarush/magento2.ubuntu"
config.vm.box_version = "~> 1.0"
config.vm.provider "virtualbox" do |vb|
vb.memory = guest_memory
end
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.synced_folder './etc', '/vagrant/etc'
config.vm.synced_folder './scripts', '/vagrant/scripts'
config.vm.synced_folder './.idea', '/vagrant/.idea', create: true
if use_nfs_for_synced_folders
guest_magento_dir = host_magento_dir
config.vm.synced_folder host_magento_dir, guest_magento_dir, type: "nfs", create: true
else
guest_magento_dir = '/var/www/magento2ce'
config.vm.synced_folder host_magento_dir + '/var/generation', guest_magento_dir + '/var/generation', create: true
config.vm.synced_folder host_magento_dir + '/app/etc', guest_magento_dir + '/app/etc', create: true
end
shell_script_args = [
use_nfs_for_synced_folders ? "1" : "0", #1
guest_magento_dir, #2
magento_host_name, #3
config_data['environment']['use_php7'], #4
host_magento_dir #5
]
config.vm.provision "configure_environment", type: "shell" do |s|
s.path = "scripts/provision/configure_environment.sh"
s.args = shell_script_args
end
if !use_nfs_for_synced_folders
config.vm.provision "host_compress_magento_code", type: "host_shell", inline: "tar cf scripts/host/magento2ce.tar magento2ce"
config.vm.provision "guest_uncompress_magento_code", type: "shell", inline: "mkdir -p /var/www && tar xf /vagrant/scripts/host/magento2ce.tar -C /var/www &>/dev/null"
config.vm.provision "guest_remove_compressed_code", type: "shell", inline: "rm -f /vagrant/scripts/host/magento2ce.tar"
end
config.vm.provision "install_magento", type: "shell", inline: "m-reinstall"
# Host manager plugin configuration
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.define magento_host_name do |node|
node.vm.hostname = magento_host_name
node.vm.network :private_network, ip: magento_ip_address
node.vm.network :forwarded_port, guest: 22, host: forwarded_ssh_port
end
config.ssh.guest_port = forwarded_ssh_port
end