2025-02-06 18:55:30 +01:00
# 🚀 Docker Mastodon with OIDC Support
2024-01-04 20:57:02 +01:00
2025-02-06 18:55:30 +01:00
## 📌 Overview
This project provides a **Docker-based setup for Mastodon** , including full **OIDC (OpenID Connect) authentication support** . It is maintained by ** [Kevin Veen-Birkenbach ](https://www.veen.world )**.
This README and some parts of the code were created with the assistance of ChatGPT. You can follow the discussion and evolution of this project in [this conversation ](https://chatgpt.com/c/67a4e19b-3884-800f-9d45-621dda2a6572 ).
## ⚙️ Configuration & Setup
2025-02-19 22:57:26 +01:00
### 🔧 Create Credentials
2025-02-06 18:55:30 +01:00
Run the following command to generate a new configuration setup:
2022-11-15 11:56:48 +01:00
```bash
2025-02-19 22:57:26 +01:00
docker pull ghcr.io/mastodon/mastodon:latest
2025-02-20 00:31:47 +01:00
# Secret Generation
2025-02-19 22:57:26 +01:00
docker run --rm ghcr.io/mastodon/mastodon:latest bundle exec rails secret
2025-02-20 00:31:47 +01:00
docker run --rm ghcr.io/mastodon/mastodon:latest bundle exec rails secret
# Vapid Key Generation
docker run --rm ghcr.io/mastodon/mastodon:latest bundle exec rails mastodon:webpush:generate_vapid_key
# ACTIVE_RECORD_ENCRYPTION Generation
docker run --rm ghcr.io/mastodon/mastodon:latest bin/rails db:encryption:init
2022-11-15 11:56:48 +01:00
```
2024-01-04 20:57:02 +01:00
2025-02-06 18:55:30 +01:00
### 🔄 Setup with an Existing Configuration
```bash
2024-01-04 20:57:02 +01:00
docker-compose run --rm web bundle exec rails db:migrate
```
2025-02-06 18:55:30 +01:00
### 🗑️ Cleanup (Remove Instance & Volumes)
2022-11-15 21:43:05 +01:00
```bash
2023-12-07 16:56:43 +01:00
cd {{path_docker_compose_instances}}mastodon/
2023-04-19 00:03:13 +02:00
docker-compose down
2022-11-15 21:43:05 +01:00
docker volume rm mastodon_data mastodon_database mastodon_redis
2023-12-07 16:56:43 +01:00
cd {{path_docker_compose_instances}} & &
rm -vR {{path_docker_compose_instances}}mastodon
2022-11-15 21:43:05 +01:00
```
2025-02-06 18:55:30 +01:00
### 🔍 Access Mastodon Terminal
2022-11-15 21:43:05 +01:00
```bash
2023-11-25 14:10:29 +01:00
docker-compose exec -it web /bin/bash
2022-11-15 21:43:05 +01:00
```
2025-02-06 18:55:30 +01:00
### 🛠️ Set File Permissions
After setting up Mastodon, apply the correct file permissions:
2022-11-15 21:43:05 +01:00
```bash
2023-11-25 14:10:29 +01:00
docker-compose exec -it -u root web chown -R 991:991 public
2022-11-15 21:43:05 +01:00
```
2022-11-15 11:56:48 +01:00
2025-02-06 18:55:30 +01:00
## 📦 Database Management
2024-11-07 23:50:46 -03:00
2025-02-06 18:55:30 +01:00
### 🏗️ Running Database Migrations
Ensure all required database structures are up to date:
2024-11-07 23:50:46 -03:00
```bash
docker compose exec -it web bash -c "RAILS_ENV=production bin/rails db:migrate"
```
2025-02-06 18:55:30 +01:00
## 🚀 Performance Optimization
### 🗑️ Delete Cache & Recompile Assets
2025-02-06 18:19:42 +01:00
```bash
docker-compose exec web bundle exec rails assets:precompile
docker-compose restart
```
2025-02-06 18:55:30 +01:00
This ensures your Mastodon instance is loading the latest assets after updates.
## 🔐 OIDC (OpenID Connect) Authentication Support
This Mastodon role now **fully supports OpenID Connect (OIDC)** , allowing seamless authentication via identity providers like **Keycloak, Auth0, Google, or other OIDC-compliant services** .
## 📚 Further Reading
- [Mastodon with Docker & Traefik ](https://goneuland.de/mastodon-mit-docker-und-traefik-installieren/ )
- [Mastodon Configuration Guide ](https://gist.github.com/TrillCyborg/84939cd4013ace9960031b803a0590c4 )
- [Check Website Availability ](https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/ )
- [Personal Mastodon Setup ](https://vitobotta.com/2022/11/07/setting-up-a-personal-mastodon-instance/ )
- [Scaling a Mastodon Server ](https://www.digitalocean.com/community/tutorials/how-to-scale-your-mastodon-server )
- [Mastodon GitHub Issues ](https://github.com/mastodon/mastodon/issues/7958 )
2024-11-07 23:50:46 -03:00