Mastodon¶
Decentralized Social Networking
Mastodon is a free, open-source social network server based on ActivityPub. It's part of the fediverse - a collection of federated social networks that can communicate with each other, giving users freedom, control, and choice over their social media experience.
Why Choose Mastodon?¶
- Federated - decentralized social network, you own your data
- Privacy-focused - no tracking or surveillance advertising
- Community-driven - transparent moderation with custom emojis
- Open source - AGPL-3.0 licensed with rich API
Install¶
Infrastructure as Code
This Mastodon instance is deployed using OpenTofu with custom Incus images. The infrastructure configuration manages container provisioning and persistent storage volumes.
Custom Mastodon Image
The Mastodon Incus image is built and maintained at forgejo.benoit.jp.net/Benoit/Laminar.
Infrastructure Configuration¶
The OpenTofu configuration provisions:
- Incus instance running custom Mastodon image
- Two persistent storage volumes:
/home/mastodon/live/public/system- Media files and attachments/home/mastodon/backup- Backup storage
resource "incus_storage_volume" "mastodon_home_mastodon_live_public_system" {
name = "mastodon_home_mastodon_live_public_system"
pool = incus_storage_pool.default.name
config = {
"initial.gid" = "1001"
"initial.uid" = "1001"
"initial.mode" = "755"
}
}
resource "incus_storage_volume" "mastodon_home_mastodon_backup" {
name = "mastodon_home_mastodon_backup"
pool = incus_storage_pool.default.name
config = {
"initial.gid" = "1001"
"initial.uid" = "1001"
"initial.mode" = "755"
}
}
resource "incus_instance" "mastodon" {
name = "mastodon"
image = "laminar.incus:mastodon-4.5.0-3benoitjpnet"
device {
name = "home_mastodon_live_public_system"
type = "disk"
properties = {
path = "/home/mastodon/live/public/system"
source = incus_storage_volume.mastodon_home_mastodon_live_public_system.name
pool = incus_storage_pool.default.name
}
}
device {
name = "home_mastodon_backup"
type = "disk"
properties = {
path = "/home/mastodon/backup"
source = incus_storage_volume.mastodon_home_mastodon_backup.name
pool = incus_storage_pool.default.name
}
}
}
Deploy Infrastructure¶
Initial Configuration¶
After provisioning, follow the official Mastodon documentation for generating configuration.
TLS Configuration
The SSL certificate generation steps can be skipped. Instead, configure nginx to listen on HTTP only, as this instance runs behind a reverse proxy that handles TLS termination.
Upgrade¶
Incus Image Upgrade
When upgrading to a newer Incus image version, follow these steps to migrate your data.
Backup current instance data before upgrading:
Dump PostgreSQL database
Deploy to new Incus image and restore data:
Update OpenTofu configuration
Edit your OpenTofu configuration file to update the image version:
Setup and restore database
Configure nginx
Enable systemd services
Upgrade Complete
Your Mastodon instance is now running on the new Incus image!
Maintenance¶
Regular Cleanup
Run these commands periodically to manage disk space and performance.
Remove old media
Remove profile media
Remove old preview cards
Cull inactive accounts
Prune unreachable accounts