Overview
This template provides a production‑ready Mastodon instance as a Monk runnable. You can:- Run it directly to host your own decentralized social network instance
- Inherit it in your own runnable to seamlessly add Mastodon to your community infrastructure
What this template manages
- Mastodon web application (port 3000)
- Mastodon streaming server (port 4000)
- Sidekiq background workers
- PostgreSQL database for data persistence
- Redis for caching and job queues
- Persistent volumes for media and database
- Optional Elasticsearch for full-text search
Quick start (run directly)
- Load templates
- Run Mastodon stack
- Create admin user
- Customize credentials (recommended via inheritance)
variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
- Preferred: inherit and replace variables with
secret("...")as shown below. - Alternative: fork/clone and edit the
variablesinmastodon/stack.yaml, thenmonk load MANIFESTand run.
http://localhost:3000 (or the runnable hostname inside Monk networks).
Configuration
Key variables you can customize in this template:${monk-volume-path}/mastodon, ${monk-volume-path}/postgres, and ${monk-volume-path}/redis on the host.
Use by inheritance (recommended for communities)
Inherit the Mastodon runnable in your community infrastructure. Example:Ports and connectivity
- Service:
webon TCP port3000(Web UI) - Service:
streamingon TCP port4000(Streaming API) - For federation, requires public domain with HTTPS configured
- From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve services.
Persistence and configuration
- Media files:
${monk-volume-path}/mastodon/public:/mastodon/public - PostgreSQL data:
${monk-volume-path}/postgres:/var/lib/postgresql/data - Redis data:
${monk-volume-path}/redis:/data - Ensure the host volumes are writable by the container user.
Production requirements
For production deployment:- Domain: Registered domain with DNS pointing to your server
- HTTPS: SSL/TLS certificate (Let’s Encrypt recommended)
- Email: SMTP server for notifications and confirmations
- Object Storage: S3-compatible storage for media (recommended for scalability)
- CDN: Content delivery network for media (optional but recommended)
- Backups: Regular database and media backups
Related templates
- High‑availability setup: see the
mastodon-ha/template in this repository for a clustered deployment. - Combine with monitoring tools (
prometheus-grafana/) for observability.
Troubleshooting
- If you changed secrets but the container has existing data, you may need to regenerate them or update the database.
- Ensure the host volumes are writable by the container user.
- Check logs:
- For federation issues:
- Verify domain is publicly accessible with HTTPS
- Test ActivityPub endpoint:
https://yourdomain/.well-known/webfinger
- For email issues, verify SMTP configuration in admin panel
- For slow performance, scale Sidekiq workers or optimize PostgreSQL
- Run database migrations if needed:
- Common administration tasks: