You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.4 KiB

  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. $provision = <<SCRIPT
  4. cd /vagrant # This is where the host folder/repo is mounted
  5. # Add repo for Ruby 2.3 binaries
  6. sudo apt-add-repository ppa:brightbox/ruby-ng
  7. # Add repo for NodeJS
  8. curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
  9. # Add firewall rule to redirect 80 to 3000 and save
  10. sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000
  11. echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
  12. echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
  13. sudo apt-get install iptables-persistent -y
  14. # Add packages to build and run Mastodon
  15. sudo apt-get install \
  16. git-core \
  17. ruby-build \
  18. libpq-dev \
  19. libxml2-dev \
  20. libxslt1-dev \
  21. imagemagick \
  22. nodejs \
  23. ruby2.3 \
  24. ruby2.3-dev \
  25. ruby-switch \
  26. redis-server \
  27. redis-tools \
  28. postgresql \
  29. postgresql-contrib \
  30. -y
  31. # Set Ruby 2.3 as 'ruby'
  32. sudo ruby-switch --set ruby2.3
  33. # Configure database
  34. sudo -u postgres createuser -U postgres vagrant -s
  35. sudo -u postgres createdb -U postgres mastodon_development
  36. # Install gems and node modules
  37. sudo gem install bundler
  38. bundle install
  39. yarn install
  40. # Build Mastodon
  41. bundle exec rails db:setup
  42. bundle exec rails assets:precompile
  43. SCRIPT
  44. $start = <<SCRIPT
  45. cd /vagrant
  46. export $(cat ".env.vagrant" | xargs)
  47. killall ruby2.3
  48. rails s -d -b 0.0.0.0
  49. SCRIPT
  50. VAGRANTFILE_API_VERSION = "2"
  51. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  52. config.vm.box = "ubuntu/trusty64"
  53. config.vm.provider :virtualbox do |vb|
  54. vb.name = "mastodon"
  55. vb.customize ["modifyvm", :id, "--memory", "1024"]
  56. end
  57. config.vm.hostname = "mastodon.dev"
  58. # This uses the vagrant-hostsupdater plugin, and lets you
  59. # access the development site at http://mastodon.dev.
  60. # To install:
  61. # $ vagrant plugin install hostsupdater
  62. if defined?(VagrantPlugins::HostsUpdater)
  63. config.vm.network :private_network, ip: "192.168.42.42"
  64. config.hostsupdater.remove_on_suspend = false
  65. end
  66. # Otherwise, you can access the site at http://localhost:3000
  67. config.vm.network :forwarded_port, guest: 80, host: 3000
  68. # Full provisioning script, only runs on first 'vagrant up' or with 'vagrant provision'
  69. config.vm.provision :shell, inline: $provision, privileged: false
  70. # Start up script, runs on every 'vagrant up'
  71. config.vm.provision :shell, inline: $start, run: 'always', privileged: false
  72. end