#!/usr/bin/env bash set -euox pipefail cd /home/mastodon git clone https://github.com/mastodon/mastodon.git live && cd live git checkout "$(git tag -l | grep '^v[0-9.]*$' | sort -V | tail -n 1)" git clone https://github.com/rbenv/rbenv.git ~/.rbenv { # shellcheck disable=SC2016 echo 'export PATH="$HOME/.rbenv/bin:$PATH"' # shellcheck disable=SC2016 echo 'eval "$(rbenv init -)"' # shellcheck disable=SC2016 echo 'export RAILS_ENV=production' } | tee -a ~/.bashrc ~/.profile # shellcheck disable=SC1090 source ~/.profile git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install bundle config deployment 'true' bundle config without 'development test' bundle install -j"$(getconf _NPROCESSORS_ONLN)" yarn install # Next steps are manual when container is started for the first time # https://docs.joinmastodon.org/admin/install/#generating-a-configuration # If upgrading from a previous image, just need to precompile assets: # cd live; RAILS_ENV=production bin/rails assets:precompile # cd /tmp; sudo -u postgres pg_dump -d mastodon_production -F c -f mastodon_production_backup.dump # incus file pull mastodon/tmp/mastodon_production_backup.dump /tmp/ # incus file push /tmp/mastodon_production_backup.dump mastodon2/tmp/ # incus shell mastodon2 # sudo -u postgres createdb mastodon_production # sudo -u postgres pg_restore -d mastodon_production -F c /tmp/mastodon_production_backup.dump # tootctl feeds build