Mastodon is a free, open-source social network server. A decentralized solution to commercial platforms, it avoids the risks of a single company monopolizing your communication. Anyone can run Mastodon and participate in the social network seamlessly.
An alternative implementation of the GNU social project. Based on ActivityStreams, Webfinger, PubsubHubbub and Salmon.
Click on the screenshot to watch a demo of the UI:
The project focus is a clean REST API and a good user interface. Ruby on Rails is used for the back-end, while React.js and Redux are used for the dynamic front-end. A static front-end for public resources (profiles and statuses) is also provided.
If you would like, you can support the development of this project on Patreon. Alternatively, you can donate to this BTC address: 17j2g7vpgHhLuXhN4bueZFCvdxxieyRVWd
If you want a stable release for production use, you should use tagged releases. To checkout the latest available tagged version:
git clone https://github.com/tootsuite/mastodon.git
cd mastodon
git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
LOCAL_DOMAIN
should be the domain/hostname of your instance. This is absolutely required as it is used for generating unique IDs for everything federation-relatedLOCAL_HTTPS
set it to true
if HTTPS works on your website. This is used to generate canonical URLs, which is also important when generating and parsing federation-related IDsConsult the example configuration file, .env.production.sample
for the full list. Among other things you need to set details for the SMTP server you are going to use.
The project now includes a Dockerfile
and a docker-compose.yml
file (which requires at least docker-compose version 1.10.0
).
Review the settings in docker-compose.yml
. Note that it is not default to store the postgresql database and redis databases in a persistent storage location,
so you may need or want to adjust the settings there.
Then, you need to fill in the .env.production
file:
cp .env.production.sample .env.production
nano .env.production
Do NOT change the REDIS_*
or DB_*
settings when running with the default docker configurations.
You will need to fill in, at least: LOCAL_DOMAIN
, LOCAL_HTTPS
, PAPERCLIP_SECRET
, SECRET_KEY_BASE
, OTP_SECRET
, and the SMTP_*
settings. To generate the PAPERCLIP_SECRET
, SECRET_KEY_BASE
, and OTP_SECRET
, you may use:
rake secret
Before running the first time, you need to build the images:
docker-compose build
docker-compose run --rm web rake secret
Do this once for each of those keys, and copy the result into the .env.production
file in the appropriate field.
Then you should run the db:migrate
command to create the database, or migrate it from an older release:
docker-compose run --rm web rails db:migrate
Then, you will also need to precompile the assets:
docker-compose run --rm web rails assets:precompile
before you can launch the docker image with:
docker-compose up
If you wish to run this as a daemon process instead of monitoring it on console, use instead:
docker-compose up -d
Then you may login to your new Mastodon instance by browsing to http://localhost:3000/
Following that, make sure that you read the production guide. You are probably going to want to understand how to configure Nginx to make your Mastodon instance available to the rest of the world.
The container has two volumes, for the assets and for user uploads, and optionally two more, for the postgresql and redis databases.
The default docker-compose.yml maps them to the repository's public/assets
and public/system
directories, you may wish to put them somewhere else. Likewise, the PostgreSQL and Redis images have data containers that you may wish to map somewhere where you know how to find them and back them up.
Note: The --rm
option for docker-compose will remove the container that is created to run a one-off command after it completes. As data is stored in volumes it is not affected by that container clean-up.
rake mastodon:media:clear
removes uploads that have not been attached to any status after a while, you would want to run this from a periodic cronjobrake mastodon:push:clear
unsubscribes from PuSH notifications for remote users that have no local followers. You may not want to actually do that, to keep a fuller footprint of the fediverse or in case your users will soon re-followrake mastodon:push:refresh
re-subscribes PuSH for expiring remote users, this should be run periodically from a cronjob and quite often as the expiration time depends on the particular hub of the remote userrake mastodon:feeds:clear_all
removes all timelines, which forces them to be re-built on the fly next time a user tries to fetch their home/mentions timeline. Only for troubleshootingrake mastodon:feeds:clear
removes timelines of users who haven't signed in lately, which allows to save RAM and improve message distribution. This is required to be run periodically so that when they login again the regeneration process will triggerRunning any of these tasks via docker-compose would look like this:
docker-compose run --rm web rake mastodon:media:clear
This approach makes updating to the latest version a real breeze.
git pull
to download updates from the repositorydocker-compose build
to compile the Docker image out of the changed source filesdocker-compose run --rm web rails db:migrate
to perform database migrations. Does nothing if your database is up to datedocker-compose run --rm web rails assets:precompile
to compile new JS and CSS assetsdocker-compose up -d
to re-create (restart) containers and pick up the changesDocker is great for quickly trying out software, but it has its drawbacks too. If you prefer to run Mastodon without using Docker, refer to the production guide for examples, configuration and instructions.
You can view a guide for deployment on Scalingo here.
Mastodon can run on Heroku, but it gets expensive and impractical due to how Heroku prices resource usage. You can view a guide for deployment on Heroku here, but you have been warned.
A quick way to get a development environment up and running is with Vagrant. You will need recent versions of Vagrant and VirtualBox installed.
You can find the guide for setting up a Vagrant development environment here.
You can open issues for bugs you've found or features you think are missing. You can also submit pull requests to this repository. Here are the guidelines for code contributions
IRC channel: #mastodon on irc.freenode.net