This repository has been archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Vagrantfile
71 lines (56 loc) · 2.45 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
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/hackillinois/api", create: "true", type: "rsync",
rsync__exclude: [".git", "node_modules"]
config.vm.provider :virtualbox do |vb|
vb.name = "hackillinois-api"
end
config.vm.provision "shell", privileged: true, inline: <<-DEPENDENCIES
onerror(){ echo "Command failed. Stopping execution..."; exit 1; }
trap onerror ERR
cd /tmp
echo "Updating package lists (this may take a while)"
export DEBIAN_FRONTEND=noninteractive
apt-get update
echo "Installing system packages (this may take a while)"
apt-get -y -q install python2.7 make g++ mysql-server-5.7 redis-server
ln /usr/bin/python2.7 /usr/bin/python
echo "Installing Node.js"
curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get -y -q install nodejs \
&& npm config set python python2.7 \
&& npm install -g node-gyp nodemon
echo "Installing Flyway"
wget https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/4.0.3/flyway-commandline-4.0.3-linux-x64.tar.gz -nv &>/dev/null \
&& tar -xzf flyway-commandline-4.0.3-linux-x64.tar.gz \
&& mv flyway-4.0.3 /opt/flyway-4.0.3 \
&& ln -s /opt/flyway-4.0.3/jre/bin/java /usr/local/bin/java \
&& ln -s /opt/flyway-4.0.3/flyway /usr/local/bin/flyway \
&& chmod +x /opt/flyway-4.0.3/flyway \
&& rm -rf /tmp/flyway-* \
echo "Configuring MySQL"
mysql_ssl_rsa_setup --uid=mysql &>/dev/null
service mysql restart
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass123'; FLUSH PRIVILEGES;"
mysql -u root -p"pass123" -e "CREATE DATABASE hackillinois"
DEPENDENCIES
config.vm.provision "shell", inline: <<-SETUP
onerror(){ echo "Command failed. Stopping execution..."; exit 1; }
trap onerror ERR
cd /hackillinois/api
echo "Installing API"
npm install
echo "Running migrations"
export DB_USERNAME=root
export DB_PASSWORD=pass123
export DB_HOSTNAME=127.0.0.1
export DB_PORT=3306
export DB_NAME=hackillinois
npm run dev-migrations
echo "Finishing Setup"
echo "cd /hackillinois/api" >> /home/ubuntu/.bashrc
SETUP
config.vm.network "forwarded_port", guest: 8080, host: ENV['VAGRANT_APP_PORT'] || 8080
config.vm.network "forwarded_port", guest: 3306, host: ENV['VAGRANT_DB_PORT'] || 3306
end