mastodon/Vagrantfile

97 lines
2.3 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
sudo pacman -Syu --noconfirm ruby ruby-bundler ruby-irb redis postgresql yarn
all | sudo pacman -Syu --noconfirm base-devel git libidn
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
kill "$(cat ./data/redis/redis-dev.pid)"
# 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
# TODO rest of setup and make Vagrantfile nice
# currently gets jammed seeding db/seeds/04_admin.rb
## run mastodon
#export NODE_ENV=development
#bundle exec rake assets:precompile
#bundle exec rake assets:clobber
#bundle exec rake assets:precompile
#foreman start
SCRIPT
$start = <<SCRIPT
#TODO
touch foo
# run mastodon
#cd /vagrant
#export NODE_ENV=development
#bundle exec rake assets:precompile
#bundle exec rake assets:clobber
#bundle exec rake assets:precompile
#foreman start
SCRIPT
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure("2") do |config|
config.vagrant.plugins = "vagrant-libvirt"
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.memory = 4096
libvirt.cpus = 4
end
config.vm.box = "archlinux/archlinux"
config.vm.network "forwarded_port", guest: 80, host: 8080,
host_ip: "127.0.0.1"
config.vm.hostname = "mastodon.local"
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
end