Efficient Fediverse microblogging server
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.
 
 
 
 
 
 

108 lines
3.3 KiB

  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. ENV["PORT"] ||= "9000"
  4. $provision = <<SCRIPT
  5. cd /vagrant # This is where the host folder/repo is mounted
  6. # Add firewall rule to redirect 80 to PORT and save
  7. sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port #{ENV["PORT"]}
  8. echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
  9. echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
  10. sudo apt-get install iptables-persistent -y
  11. # Add packages to build and run Mastodon
  12. sudo apt-get install \
  13. git-core \
  14. gcc \
  15. postgresql \
  16. postgresql-contrib \
  17. libpq-dev \
  18. -y
  19. # Configure database
  20. sudo -u postgres createuser -U postgres vagrant -s
  21. sudo -u postgres createdb -U postgres kibou_dev
  22. # Configure automatic loading of environment variable
  23. echo 'export $(cat "/vagrant/.env.vagrant" | xargs)' >> ~/.bash_profile
  24. curl https://sh.rustup.rs -sSf > rust.install.sh
  25. chmod u+x ./rust.install.sh
  26. ./rust.install.sh -y
  27. rustup install nightly
  28. rustup default nightly
  29. source $HOME/.cargo/env
  30. cargo install diesel_cli --no-default-features --features "postgres"
  31. echo DATABASE_URL=postgres://vagrant:vagrant@localhost/kibou_dev > .env
  32. diesel migration run
  33. sudo sh -c 'echo "192.168.42.42 mastodon.local" >> /etc/hosts'
  34. SCRIPT
  35. $start = <<SCRIPT
  36. echo 'To start server'
  37. echo ' $ vagrant ssh -c "cd /vagrant && cargo run"'
  38. SCRIPT
  39. VAGRANTFILE_API_VERSION = "2"
  40. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  41. config.vm.box = "ubuntu/bionic64"
  42. config.vm.provider :virtualbox do |vb|
  43. vb.name = "kibou"
  44. vb.customize ["modifyvm", :id, "--memory", "1024"]
  45. # Increase the number of CPUs. Uncomment and adjust to
  46. # increase performance
  47. # vb.customize ["modifyvm", :id, "--cpus", "3"]
  48. # Disable VirtualBox DNS proxy to skip long-delay IPv6 resolutions.
  49. # https://github.com/mitchellh/vagrant/issues/1172
  50. vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
  51. vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
  52. # Use "virtio" network interfaces for better performance.
  53. vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
  54. vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
  55. end
  56. # This uses the vagrant-hostsupdater plugin, and lets you
  57. # access the development site at http://mastodon.local.
  58. # If you change it, also change it in .env.vagrant before provisioning
  59. # the vagrant server to update the development build.
  60. #
  61. # To install:
  62. # $ vagrant plugin install vagrant-hostsupdater
  63. config.vm.hostname = "kibou.local"
  64. if defined?(VagrantPlugins::HostsUpdater)
  65. config.vm.network :private_network, ip: "192.168.42.43", nictype: "virtio", virtbox__itnet: true
  66. config.hostsupdater.remove_on_suspend = false
  67. end
  68. # if config.vm.networks.any? { |type, options| type == :private_network }
  69. # config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp', 'actimeo=1']
  70. # else
  71. config.vm.synced_folder ".", "/vagrant"
  72. # end
  73. config.vm.network :forwarded_port, guest: 9000, host: 9000
  74. # Full provisioning script, only runs on first 'vagrant up' or with 'vagrant provision'
  75. config.vm.provision :shell, inline: $provision, privileged: false
  76. # Start up script, runs on every 'vagrant up'
  77. config.vm.provision :shell, inline: $start, run: 'always', privileged: false
  78. end