闭社主体 forked from https://github.com/tootsuite/mastodon
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.

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