6 cd /vagrant # This is where the host folder/repo is mounted
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'
13 curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
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
21 # Add packages to build and run Mastodon
22 sudo apt-get install \
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
44 git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
46 export PATH="$HOME/.rbenv/bin:$PATH"
47 eval "$(rbenv init -)"
51 echo "Compiling Ruby $(cat .ruby-version): warning, this takes a while!!!"
52 rbenv install $(cat .ruby-version)
53 rbenv global $(cat .ruby-version)
56 sudo -u postgres createuser -U postgres vagrant -s
57 sudo -u postgres createdb -U postgres mastodon_development
59 # Install gems and node modules
65 bundle exec rails db:setup
66 bundle exec rails assets:precompile
73 export $(cat ".env.vagrant" | xargs)
78 VAGRANTFILE_API_VERSION = "2"
80 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
82 config.vm.box = "ubuntu/trusty64"
84 config.vm.provider :virtualbox do |vb|
86 vb.customize ["modifyvm", :id, "--memory", "1024"]
88 # Disable VirtualBox DNS proxy to skip long-delay IPv6 resolutions.
89 # https://github.com/mitchellh/vagrant/issues/1172
90 vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
91 vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
93 # Use "virtio" network interfaces for better performance.
94 vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
95 vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
99 config.vm.hostname = "mastodon.dev"
101 # This uses the vagrant-hostsupdater plugin, and lets you
102 # access the development site at http://mastodon.dev.
104 # $ vagrant plugin install vagrant-hostsupdater
105 if defined?(VagrantPlugins::HostsUpdater)
106 config.vm.network :private_network, ip: "192.168.42.42", nictype: "virtio"
107 config.hostsupdater.remove_on_suspend = false
110 if config.vm.networks.any? { |type, options| type == :private_network }
111 config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp']
113 config.vm.synced_folder ".", "/vagrant"
116 # Otherwise, you can access the site at http://localhost:3000
117 config.vm.network :forwarded_port, guest: 80, host: 3000
119 # Full provisioning script, only runs on first 'vagrant up' or with 'vagrant provision'
120 config.vm.provision :shell, inline: $provision, privileged: false
122 # Start up script, runs on every 'vagrant up'
123 config.vm.provision :shell, inline: $start, run: 'always', privileged: false