Difference between revisions of "Mastodon"

From Organic Design wiki
m (Installation)
(Installation: Installation on a dedicated server without Docker)
Line 2: Line 2:
  
 
== Installation ==
 
== 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 [https://joinmastodon.org/ Docker image] is definitely the preferred route, but it's till quite complicated and needs to be done via Docker Compose.
+
Mastodon has a lot of dependencies that we don't have installed on our server such as PostgreSQL and Ruby, so for us the [https://joinmastodon.org/ Docker image] is definitely the preferred route, but it's till quite complicated and needs to be done via Docker Compose based on the [https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Docker-Guide.md 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.
 
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.
Line 19: Line 19:
 
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.
 
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 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.
 
<source lang="bash">
 
<source lang="bash">
docker-compose run --rm web rake secret
+
docker-compose run --rm web bundle exec rake mastodon:setup
docker-compose run --rm web rake secret
 
docker-compose run --rm web rake mastodon:webpush:generate_vapid_key
 
 
</source>
 
</source>
  
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.
+
 
 +
Then if all has gone well, you can run the instance:
 +
<source lang="bash">
 +
docker-compose up -d
 +
</source>
 +
 
 +
== See also ==
 +
*[https://docs.joinmastodon.org/administration/installation/ Installation on a dedicated server without Docker]

Revision as of 19:37, 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 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

See also