Mastodon
Mastodon is a free, open-source social network server based on ActivityPub. Follow friends and discover new ones. Publish anything you want: links, pictures, text, video. All servers of Mastodon are interoperable as a federated network, i.e. users on one server can seamlessly communicate with users from another one. This includes non-Mastodon software that also implements ActivityPub! The easiest way to get started on Mastodon is to join one of the existing servers, but here at OD we're running our own instance which we're documenting here.
Installation
Mastodon has a lot of dependencies that we don't have installed on our server such as PostgreSQL and Ruby, so for us the Docker image is definitely the preferred route, but it's till quite complicated and needs to be done via Docker Compose based on the official installation.
First, create a mastodon group with number 991 which is used by the project, then create a directory for the persistent data that will be used by the containers (we're putting our repo and data in /var/www/domains along with other web applications - this is not under our document root!), clone the Mastodon Docker repo and checkout the latest stable version.
groupadd -g 991 mastodon
useradd -u 991 -g 991 -c "Mastodon User" -s /usr/bin/nologin -d /var/www/domains/mastodon-data mastodon
mkdir /var/www/domains/mastodon-data
cd /var/www/domains
git clone https://github.com/tootsuite/mastodon.git mastodon-docker
chown -R mastodon:mastodon /var/www/domains/mastodon*
cd mastodon-docker
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
Before running any docker-compose commands we need to edit the docker-compose.yml file. Change all the images to use the vesion of the repo you chose above, e.g. "image: tootsuite/mastodon:v2.2.0". Uncomment all the volume path lines for data persistence. The host part (the path before the colon) of each needs to be changed to the absolute data path you set above (in our case /var/www/domains/mastodon-data) instead of just a relative "./path". You may want to enable the elastic search section too. I like to change the restart options from "always" to "unless-stopped" as well.
Now copy the .env.production.sample to .env.production and run the setup wizard. Note that most of the questions can be just set as default by entering nothing. Answer "yes" to save the configuration, create the schema and admin user etc.
docker-compose run --rm web bundle exec rake mastodon:setup
Then if all has gone well, you can run the instance:
docker-compose up -d