forked from the-blue-alliance/the-blue-alliance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
executable file
·96 lines (83 loc) · 2.52 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
# -*- mode: ruby -*-
# vi: set ft=ruby:expandtab:tabstop=2:softtabstop=2
Vagrant.require_version "> 1.8.1"
# Install vagrant plugin
# From: https://github.com/hashicorp/vagrant/issues/1874#issuecomment-165904024
# @param: plugin type: Array[String] desc: The desired plugin to install
def ensure_plugins(plugins)
logger = Vagrant::UI::Colored.new
result = false
plugins.each do |p|
pm = Vagrant::Plugin::Manager.new(
Vagrant::Plugin::Manager.user_plugins_file
)
plugin_hash = pm.installed_plugins
next if plugin_hash.has_key?(p)
result = true
logger.warn("Installing plugin #{p}")
if not system "vagrant plugin install #{p}"
logger.error("Unable to install plugin #{p}")
exit -1
end
end
if result
logger.warn('Re-run vagrant up now that plugins are installed')
exit
end
end
# Make sure we have all the proper plugins installed
ensure_plugins(["vagrant-triggers"])
Vagrant.configure("2") do |config|
# Sync the TBA code directory
config.vm.synced_folder "./", "/tba",
type: "rsync",
owner: "root",
group: "root",
rsync__rsync_path: "rsync",
rsync__exclude: [
".git/",
"node_modules/",
"lib/",
"static/compiled/",
],
rsync__auto: true
# Forward GAE modules
ports = []
for i in 8080..8089
ports.push("#{i}:#{i}")
config.vm.network "forwarded_port", guest: i, host: i
end
# Forward GAE admin
ports.push("8000:8000")
config.vm.network "forwarded_port", guest: 8000, host: 8000
# Provision with docker
config.vm.hostname = "tba-docker"
config.vm.provider "docker" do |d|
d.name = "tba"
d.build_dir = "ops/dev"
d.ports = ports
d.has_ssh = true
end
# Configure ssh into container
config.ssh.insert_key = true
config.ssh.username = "root"
config.ssh.password = "tba"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# Provision dependencies
config.vm.provision "shell",
inline: "cd /tba && ./ops/dev/bootstrap-dev-container.sh",
privileged: false
# Load in the datastore file, needs to run before devserver start
config.vm.provision "shell",
inline: "cd /tba && ./ops/dev/pull-datastore.sh push",
privileged: false
# Start the GAE devserver
config.vm.provision "shell",
inline: "cd /tba && ./ops/dev/start-devserver.sh",
privileged: false,
run: "always"
# When the container halts, pull the datastore files
config.trigger.before [:halt, :destroy],
inline: "cd /tba && ./ops/dev/pull-datastore.sh pull",
privileged: false
end