This is precisely the sort of thing I'd love to see shoved into a script or template instead of just a list of commands to run within a jail. For instance this would be perfect for a small ansible playbook using the jail connector. Or if you use iocage instead of bastille you could use nomad to build the image and/or distribute it as a ZFS snapshot
More nitpicky I'd drop the -j foo for bundle install as bundler already defaults to the number of processors (https://bundler.io/v2.3/man/bundle-install.1.html). I'd also suggest creating a UTF-8 login class and adding the mastodon and postgres users to that class instead of monkeying with shell init files since that'll work for any shell no matter how it's been invoked.
With postgres on a single combined instance I'd also drop all of the networking stuff. By default postgres should be listening on an AF_LOCAL socket and it should all just work. Rails should let you specify a path to a socket instead of a host/port combo, and psql(1) should default to looking for the socket.
More nitpicky I'd drop the -j foo for bundle install as bundler already defaults to the number of processors (https://bundler.io/v2.3/man/bundle-install.1.html). I'd also suggest creating a UTF-8 login class and adding the mastodon and postgres users to that class instead of monkeying with shell init files since that'll work for any shell no matter how it's been invoked.
With postgres on a single combined instance I'd also drop all of the networking stuff. By default postgres should be listening on an AF_LOCAL socket and it should all just work. Rails should let you specify a path to a socket instead of a host/port combo, and psql(1) should default to looking for the socket.