Running Takahē on Dokku

Takahē is a new, lightweight, django-based ActivityPub implementation by Andrew Godwin that's best suited for small to medium installs (think you, your family, and your friends) that supports multiple domain names out of the box.

Dokku is a Heroku clone (and much more) that you can self-host and is great for hosting all your little projects. We're going to use it to host Takahē in 5 minutes. I'm going to assume you've already got Dokku running, so we won't cover the setup.

Step one, create the application:

dokku apps:create takahe

Step two, create a postgres database to go with it:

dokku postgres:create takahe

Step three, link our newly created database to our application:

dokku postgres:link takahe takahe

Step four, a small workaround as Takahē uses the environment variable DATABASE_SERVER instead of the Heroku/Dokku default of DATABASE_URL:

dokku config:set takahe TAKAHE_DATABASE_SERVER=$(dokku config:get takahe DATABASE_URL)

Step five, set our other environment variables. Update these as required:

dokku config:set takahe TAKAHE_ENVIRONMENT=production
dokku config:set takahe TAKAHE_SECRET_KEY=ChangeThisToALongRandomString
dokku config:set takahe TAKAHE_STATOR_KEY=ChangeThisToALongRandomString
dokku config:set takahe
dokku config:set takahe TAKAHE_USE_PROXY_HEADERS=true
dokku config:set takahe TAKAHE_CSRF_HOSTS="[\"\"]"
dokku config:set takahe TAKAHE_ALLOWED_HOSTS="[\"\"]"
dokku config:set takahe TAKAHE_CORS_HOSTS="[\"\"]"

Step six, set the domain name you're going to use for your Takahē install:

dokku domains:set takahe

Step seven, lets set up SSL with letsencrypt. Keep in mind you'll need your domain already setup to point to dokku:

dokku config:set takahe
dokku letsencrypt:enable takahe

Step eight, checkout the code and deploy. Don't forget to :

git clone
cd takahe
git remote add dokku <your dokku username>@<your dokku server>:takahe
git push dokku main:master

And finally, lets run the database migrations to populate our database, start a background worker, and create our admin user:

dokku run takahe python migrate
dokku ps:scale takahe worker=1
dokku run takahe ptyhon createsuperuser

And you're done!


Can't upload large images

By default, the nginx template dokku uses will only allow 1mb uploads. Fix that by doing:

echo 'client_max_body_size 50m;' > /home/dokku/takahe/nginx.conf.d/upload.conf
chown dokku:dokku /home/dokku/takahe/nginx.conf.d/upload.conf
service nginx.load