Mastodon
2022-11-03
So all the cool nerds seem to be signing up for Mastodon at the moment, ever since Elongate and I thought ‘why not?’.
I looked them up on Github, saw a Dockerfile and thought ‘Nice, this should be fairly easy then’. Oh how wrong I was.
It turns out that to run Mastodon you don’t just run the one container, you need do run a whole mesh of 3-5 containers. 3 of which are the same tootsuite/mastodon
container, but with different commands. The documentation is absolutely shocking when it comes to Docker, so I had to piece it all together from bits of their Documentation along with the docker-compose.yaml
and .env.production.sample
files which were in the repo.
Eventually I found this command, and it changed everything: docker run -e RAILS_ENV=production -it tootsuite/mastodon bundle exec rake mastodon:setup
. This will do several things:
- Ask you a bunch of questions about your set up, like domain, database info etc.
- Amalgamate these into a .env file, and also print them to stdout.
- Prepare the database, which I’d had issues with before running this command due to missing tables etc.
Below is a redacted list of all the environment variables used lifted from my ECS task definition. Please make use of them, if it’s helpful!
{
"environment": [
{
"name": "LOCAL_DOMAIN",
"value": "REDACTED"
},
{
"name": "S3_REGION",
"value": "REDACTED"
},
{
"name": "DB_PORT",
"value": "REDACTED"
},
{
"name": "DB_USER",
"value": "REDACTED"
},
{
"name": "AWS_SECRET_ACCESS_KEY",
"value": "REDACTED"
},
{
"name": "DB_NAME",
"value": "REDACTED"
},
{
"name": "SMTP_LOGIN",
"value": "REDACTED"
},
{
"name": "VAPID_PRIVATE_KEY",
"value": "REDACTED"
},
{
"name": "SMTP_PORT",
"value": "REDACTED"
},
{
"name": "REDIS_PORT",
"value": "REDACTED"
},
{
"name": "AWS_ACCESS_KEY_ID",
"value": "REDACTED"
},
{
"name": "DB_PASS",
"value": "REDACTED"
},
{
"name": "SMTP_PASSWORD",
"value": "REDACTED"
},
{
"name": "SMTP_SERVER",
"value": "REDACTED"
},
{
"name": "VAPID_PUBLIC_KEY",
"value": "REDACTED"
},
{
"name": "OTP_SECRET",
"value": "REDACTED"
},
{
"name": "S3_BUCKET",
"value": "REDACTED"
},
{
"name": "REDIS_HOST",
"value": "REDACTED"
},
{
"name": "S3_HOSTNAME",
"value": "REDACTED"
},
{
"name": "RAILS_ENV",
"value": "REDACTED"
},
{
"name": "S3_PROTOCOL",
"value": "REDACTED"
},
{
"name": "DB_HOST",
"value": "REDACTED"
},
{
"name": "SMTP_FROM_ADDRESS",
"value": "REDACTED"
},
{
"name": "S3_ENABLED",
"value": "REDACTED"
},
{
"name": "SECRET_KEY_BASE",
"value": "REDACTED"
}
]
The other massive thing that I had trouble with was the command field as 3 of the 5 services are the same tootsuite/mastodon
container but running different rake
commands.
Use the exec form of the command, but leave the quotes out. ECS will escape any quotes and this causes all kinds of headaches. Your command for the web container should just be:
/usr/bin/bash,-c,rm -f /mastodon/tmp/pids/server.pid;bundle exec rails s -p 3000
in the console, or "command": ["/usr/bin/bash","-c","rm -f /mastodon/tmp/pids/server.pid;bundle exec rails s -p 3000"],
in the JSON.