mastodon/Vagrantfile

89 lines
2.1 KiB
Ruby

# -*- mode: ruby -*-
# vi: set ft=ruby :
REQUIRED_PLUGINS = %w(vagrant-libvirt)
exit unless REQUIRED_PLUGINS.all? do |plugin|
Vagrant.has_plugin?(plugin) || (
puts "The #{plugin} plugin is required. Please install it with:"
puts "$ vagrant plugin install #{plugin}"
false
)
end
$provision = <<SCRIPT
# see SETUP.md for details
# packages
#all | sudo pacman -Syu --noconfirm base-devel
sudo pacman -Syu --noconfirm base-devel git libidn
sudo pacman -Syu --noconfirm ruby ruby-bundler ruby-irb redis postgresql yarn
git clone https://aur.archlinux.org/ruby-foreman.git
cd ruby-foreman
yes | sudo -u vagrant makepkg -si
# treehouse mastodon files are synced here
cd /vagrant
## database
if [ -d "data/" ]; then rm -rf data/; fi
mkdir -p data/
pg_ctl -D data/postgres initdb -o '-U mastodon --auth-host=trust'
echo 'unix_socket_directories = .' >> data/postgres/postgresql.conf
pg_ctl -D data/postgres start --silent
# redis
mkdir -p data/redis
redis-server ./redis-dev.conf
# ruby
export RAILS_ENV=development
if [ -d "vendor/bundle/" ]; then rm -rf vendor/bundle/; fi
bundle config set --local path 'vendor/bundle/'
bundle install
yarn install
bundle exec rake db:setup
# run mastodon
export NODE_ENV=development
bundle exec rake assets:precompile
foreman start
SCRIPT
$start = <<SCRIPT
export NODE_ENV=development
export RAILS_ENV=development
cd /vagrant
pg_ctl -D data/postgres start --silent
redis-server ./redis-dev.conf
foreman start
SCRIPT
Vagrant.configure("2") do |config|
config.vagrant.plugins = "vagrant-libvirt"
config.vm.box = "archlinux/archlinux"
config.vm.hostname = "mastodon.local"
# vagrant ssh -- -R 3000:localhost:3000 (:
#config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.synced_folder ".", "/vagrant",
type: "rsync",
rsync__args: ["--verbose", "--archive", "--delete", "-z"],
rsync__exclide: ".git/"
config.vm.provision :shell, inline: $provision, privileged: false
config.vm.provision :shell, inline: $start, run: 'always', privileged: false
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.memory = 4096
libvirt.cpus = 4
end
end