Difference between revisions of "Mastodon"

From Organic Design wiki
m (Installation: unless-stopped)
m (Installation)
Line 17: Line 17:
  
  
Before running any ''docker-compose'' commands we need to edit the ''docker-compose.yml'' file, and 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.
+
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 we need to create a ''.env.production'' file which first requires the following commands to create some secrets and keys. The first command will take a long time since it will be pulling down many new Docker images.
 
Now we need to create a ''.env.production'' file which first requires the following commands to create some secrets and keys. The first command will take a long time since it will be pulling down many new Docker images.

Revision as of 16:10, 28 October 2018

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.

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 we need to create a .env.production file which first requires the following commands to create some secrets and keys. The first command will take a long time since it will be pulling down many new Docker images.

docker-compose run --rm web rake secret
docker-compose run --rm web rake secret
docker-compose run --rm web rake mastodon:webpush:generate_vapid_key

Then copy the .env.production.sample to .env.production and edit it. Set your LOCAL_DOMAIN to the domain your instance will be running on, and the SMTP section according to the file comments and your servers mail settings. Set SECRET_KEY_BASE and OTP_SECRET to the two secrets respectively and VAPID_PRIVATE_KEY and VAPID_PUBLIC_KEY to the generated key pair.