This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Vagrantfile
143 lines (108 loc) · 3.95 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "rethinkdb" do |rethinkdb|
rethinkdb.vm.box="geerlingguy/ubuntu1404"
rethinkdb.vm.box_version = "1.1.0"
rethinkdb.vm.network "private_network", ip:"10.0.32.2"
rethinkdb.vm.provider "virtualbox" do |v|
v.memory = 256
end
rethinkdb.vm.provision :shell do |sh|
sh.inline = <<-EOF
if [ ! -f /var/lock/provision.lock ]; then
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
apt-get update --assume-yes
apt-get install rethinkdb=2.0.5~0trusty --assume-yes
cat > /etc/rethinkdb/instances.d/instance1.conf <<EOL
runuser=vagrant
rungroup=vagrant
bind=all
EOL
touch /var/lock/provision.lock
fi
service rethinkdb restart
EOF
end
end
config.vm.define "redis" do |redis|
redis.vm.box="geerlingguy/ubuntu1404"
redis.vm.box_version = "1.1.0"
redis.vm.network "private_network", ip:"10.0.32.3"
redis.vm.provider "virtualbox" do |v|
v.memory = 256
end
redis.vm.provision :shell do |sh|
sh.inline = <<-EOF
if [ ! -f /var/lock/provision.lock ]; then
apt-get update --assume-yes
apt-get install redis-server --assume-yes
sed -i 's/bind\ 127\.0\.0\.1/bind 0\.0\.0\.0/' /etc/redis/redis.conf
fi
service redis-server restart
EOF
end
end
config.vm.define "compose" do |compose|
compose.vm.box="geerlingguy/ubuntu1404"
compose.vm.box_version = "1.1.0"
compose.vm.network "private_network", ip:"10.0.32.4"
compose.vm.provider "virtualbox" do |v|
v.memory = 256
end
compose.vm.provision :shell do |sh|
sh.inline = <<-EOF
export GOPATH=/home/vagrant/go
if [ ! -f /var/lock/provision.lock ]; then
add-apt-repository ppa:ubuntu-lxc/lxd-stable --yes
apt-get update --assume-yes
apt-get install golang=2:1.6-1ubuntu2~ubuntu14.04.1~ppa1 --assume-yes
echo "Setting Go Workspace"
mkdir -p /home/vagrant/go/src
mkdir -p /home/vagrant/go/pkg
mkdir -p /home/vagrant/go/bin
go get -u github.com/tools/godep
echo "Linking platform-ws-services"
mkdir -p $GOPATH/src/github.com/compose
ln -s /vagrant $GOPATH/src/github.com/compose/platform-ws-services
cat > /etc/init/platform-ws-services.conf <<EOL
# platform-ws-services
description "platform-ws-services daemon"
author "Compose.io"
# Listen and start after the vagrant-mounted event
start on net-device-up IFACE=eth1 and runlevel [2345]
stop on runlevel [!2345]
script
while [ ! -f /vagrant/setup-env.sh ]
do
sleep 1
done
. /home/vagrant/go/src/github.com/compose/platform-ws-services/setup-env.sh
exec /home/vagrant/go/bin/platform-ws-services --bind=0.0.0.0 2>&1 | tee -a /var/log/platform-ws-services.log /vagrant/platform-ws-services.log
end script
EOL
initctl reload-configuration
touch /var/lock/provision.lock
fi
echo "Restoring project environment"
cd $GOPATH/src/github.com/compose/platform-ws-services
$GOPATH/bin/godep restore
go get -t .
echo "Running Tests"
go test -v
echo "Building platform-ws-services"
source ./setup-env.sh
go build
echo "Cleaning up any old deployments"
service platform-ws-services stop
echo "Seeding Databases"
go test -tags=seed
echo "Launching Compose Service"
service platform-ws-services restart
EOF
end
end
end