HOW-TO: Upgrading Mastodon as a Digital Ocean Droplet
References
- https://www.digitalocean.com/community/questions/im-searching-how-to-upgrade-my-mastodon-instance-hosted-on-digital-ocean
- https://docs.joinmastodon.org/admin/upgrading/
- https://github.com/mastodon/mastodon/releases
HOW-TO: Upgrading Mastodon
SSH into your droplet
ssh yourdomain.com
Some of these steps could take a while to complete, you may want to consider persisting your session with screen or tmux, so you can come back to long-running processes if your ssh connection breaks.
screen
Switch to the mastodon user
sudo su - mastodon
Move to the mastodon directory
cd live
Make sure you have the latest tag and check into it
git fetch && git checkout v4.1.3
The major version bump introduced an update to the Ruby version, you’ll have to install it. This will take quite a long time, go grab a a meal.
rbenv install $(cat .ruby-version) --verbose
Install the gems for the new version
bundle install
Run the new rails migrations in production mode
RAILS_ENV=production bin/rails db:migrate
Install a fresh set of node packages
rm -rf node_modules && yarn install
Build the JS bundle
yarn build:production
Exit the mastodon user
logout
Restart all the services
sudo systemctl restart mastodon-web.service sudo systemctl restart mastodon-sidekiq.service sudo systemctl restart mastodon-streaming.service
And done, you’re on the latest version of Mastodon.