This repository has been archived by the owner on May 26, 2020. It is now read-only.
forked from mysociety/alavetelitheme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
122 lines (111 loc) · 3.98 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Welcome! Thanks for taking an interest in contributing to Alaveteli.
# This Vagrantfile should get you started with the minimum of fuss.
#
# Usage
# =====
#
# Get a copy of Alaveteli from GitHub and create the Vagrant instance
#
# # Host
# $ git clone [email protected]:mysociety/alaveteli.git
# $ cd alaveteli
# $ git submodule update --init
# $ vagrant --no-color up
#
# You should now be able to ssh in to the guest and run the test suite
#
# # Host
# $ vagrant ssh
#
# # Guest
# $ cd /home/vagrant/alaveteli
# $ bundle exec rake spec
#
# Run the rails server and visit the application in your host browser
# at http://10.10.10.30:3000
#
# # Guest
# bundle exec rails server
#
# Customizing the Vagrant instance
# ================================
#
# This Vagrantfile allows customisation of some aspects of the virtaual machine
# See the customization options below for details.
#
# The options can be set either by prefixing the vagrant command, or by
# exporting to the environment.
#
# # Prefixing the command
# $ ALAVETELI_VAGRANT_MEMORY=2048 vagrant up
#
# # Exporting to the environment
# $ export ALAVETELI_VAGRANT_MEMORY=2048
# $ vagrant up
#
# Both have the same effect, but exporting will retain the variable for the
# duration of your shell session.
#
# Using Themes
# ------------
#
# You can also use the built in theme switcher (script/switch-theme.rb). The
# ALAVETELI_THEMES_DIR will be shared in to /home/vagrant/alaveteli-themes so
# that the default location is used on the guest. You can use the env var
# ALAVETELI_THEMES_DIR to change where this Vagrantfile looks for the themes
# directory on the host.
#
# Customization Options
# =====================
ALAVETELI_FQDN = ENV['ALAVETELI_VAGRANT_FQDN'] || "alaveteli.10.10.10.30.xip.io"
ALAVETELI_MEMORY = ENV['ALAVETELI_VAGRANT_MEMORY'] || 1536
ALAVETELI_THEMES_DIR = ENV['ALAVETELI_THEMES_DIR'] || '../alaveteli-themes'
ALAVETELI_OS = ENV['ALAVETELI_VAGRANT_OS'] || 'precise64'
SUPPORTED_OPERATING_SYSTEMS = {
'precise64' => 'https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box',
'wheezy64' => 'http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box'
}
def box
ALAVETELI_OS
end
def box_url
SUPPORTED_OPERATING_SYSTEMS[ALAVETELI_OS]
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = box
config.vm.box_url = box_url
config.vm.network :private_network, :ip => "10.10.10.30"
config.vm.synced_folder ".", "/home/vagrant/alaveteli", :owner => "vagrant", :group => "vagrant"
if File.directory?(ALAVETELI_THEMES_DIR)
config.vm.synced_folder ALAVETELI_THEMES_DIR,
"/home/vagrant/alaveteli-themes",
:owner => "vagrant",
:group => "vagrant"
end
config.ssh.forward_agent = true
# The bundle install fails unless you have quite a large amount of
# memory; insist on 1.5GiB:
config.vm.provider "virtualbox" do |vb|
host = RbConfig::CONFIG['host_os']
# Give VM access to all cpu cores on the host
if host =~ /darwin/
cpus = `sysctl -n hw.ncpu`.to_i
elsif host =~ /linux/
cpus = `nproc`.to_i
else # sorry Windows folks, I can't help you
cpus = 1
end
vb.customize ["modifyvm", :id, "--memory", ALAVETELI_MEMORY]
vb.customize ["modifyvm", :id, "--cpus", cpus]
end
# Fetch and run the install script:
config.vm.provision :shell, :inline => "apt-get -y install curl"
config.vm.provision :shell, :inline => "curl -O https://raw.githubusercontent.com/mysociety/commonlib/master/bin/install-site.sh"
config.vm.provision :shell, :inline => "chmod a+rx install-site.sh"
config.vm.provision :shell, :inline => "./install-site.sh " \
"--dev " \
"alaveteli " \
"vagrant " \
"#{ ALAVETELI_FQDN }"
end