]> cat aescling's git repositories - mastodon.git/blob - Vagrantfile
Use NFS for the shared folder because it dramatically decreases latency for git opera...
[mastodon.git] / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 $provision = <<SCRIPT
5
6 cd /vagrant # This is where the host folder/repo is mounted
7
8 # Add the yarn repo + yarn repo keys
9 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
10 sudo apt-add-repository 'deb https://dl.yarnpkg.com/debian/ stable main'
11
12 # Add repo for NodeJS
13 curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
14
15 # Add firewall rule to redirect 80 to 3000 and save
16 sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000
17 echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
18 echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
19 sudo apt-get install iptables-persistent -y
20
21 # Add packages to build and run Mastodon
22 sudo apt-get install \
23 git-core \
24 g++ \
25 libpq-dev \
26 libxml2-dev \
27 libxslt1-dev \
28 imagemagick \
29 nodejs \
30 redis-server \
31 redis-tools \
32 postgresql \
33 postgresql-contrib \
34 yarn \
35 libreadline-dev \
36 -y
37
38 # Install rbenv
39 git clone https://github.com/rbenv/rbenv.git ~/.rbenv
40 cd ~/.rbenv && src/configure && make -C src
41 echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
42 echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
43
44 git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
45
46 export PATH="$HOME/.rbenv/bin::$PATH"
47 eval "$(rbenv init -)"
48
49 echo "Compiling Ruby 2.3.1: warning, this takes a while!!!"
50 rbenv install 2.3.1
51 rbenv global 2.3.1
52
53 cd /vagrant
54
55 # Configure database
56 sudo -u postgres createuser -U postgres vagrant -s
57 sudo -u postgres createdb -U postgres mastodon_development
58
59 # Install gems and node modules
60 gem install bundler
61 bundle install
62 yarn install
63
64 # Build Mastodon
65 bundle exec rails db:setup
66 bundle exec rails assets:precompile
67
68 SCRIPT
69
70 $start = <<SCRIPT
71
72 cd /vagrant
73 export $(cat ".env.vagrant" | xargs)
74 rails s -d -b 0.0.0.0
75
76 SCRIPT
77
78 VAGRANTFILE_API_VERSION = "2"
79
80 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
81
82 config.vm.box = "ubuntu/trusty64"
83
84 config.vm.provider :virtualbox do |vb|
85 vb.name = "mastodon"
86 vb.customize ["modifyvm", :id, "--memory", "1024"]
87 end
88
89 config.vm.hostname = "mastodon.dev"
90
91 # This uses the vagrant-hostsupdater plugin, and lets you
92 # access the development site at http://mastodon.dev.
93 # To install:
94 # $ vagrant plugin install hostsupdater
95 if defined?(VagrantPlugins::HostsUpdater)
96 config.vm.network :private_network, ip: "192.168.42.42"
97 config.hostsupdater.remove_on_suspend = false
98 end
99
100 config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp']
101
102 # Otherwise, you can access the site at http://localhost:3000
103 config.vm.network :forwarded_port, guest: 80, host: 3000
104
105 # Full provisioning script, only runs on first 'vagrant up' or with 'vagrant provision'
106 config.vm.provision :shell, inline: $provision, privileged: false
107
108 # Start up script, runs on every 'vagrant up'
109 config.vm.provision :shell, inline: $start, run: 'always', privileged: false
110
111 end
This page took 0.086676 seconds and 4 git commands to generate.