Installation
Docker Compose
services:
db:
image: postgres:15
container_name: mastodon_db
environment:
POSTGRES_USER: mastodon
POSTGRES_PASSWORD: mastodon_password
POSTGRES_DB: mastodon_production
volumes:
- mastodon_postgres:/var/lib/postgresql/data
redis:
image: redis:7
container_name: mastodon_redis
command: ["redis-server", "--save", "60", "1", "--loglevel", "warning"]
volumes:
- mastodon_redis:/data
web:
image: tootsuite/mastodon:v4.2.0
container_name: mastodon_web
depends_on:
- db
- redis
env_file: .env
command: bash -c "RAILS_ENV=production bundle exec rails s -p 3000 -b '0.0.0.0'"
ports:
- "3000:3000"
volumes:
- mastodon_public:/mastodon/public
restart: always
streaming:
image: tootsuite/mastodon:v4.2.0
container_name: mastodon_streaming
depends_on:
- redis
env_file: .env
command: npm run start
ports:
- "4000:4000"
restart: always
sidekiq:
image: tootsuite/mastodon:v4.2.0
container_name: mastodon_sidekiq
depends_on:
- db
- redis
env_file: .env
command: bash -c "RAILS_ENV=production bundle exec sidekiq"
restart: always
caddy:
image: caddy:latest
container_name: mastodon_caddy
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes:
mastodon_postgres:
mastodon_redis:
mastodon_public:
caddy_data:
caddy_config:
Generate Secret
Repeat following command for:
-
SECRET_KEY_BASE
-
OTP_SECRET
docker run --rm tootsuite/mastodon:v4.2.0 bundle exec rake secret
Generate VAPID keys:
docker run --rm tootsuite/mastodon:v4.2.0 bundle exec rake mastodon:webpush:generate_vapid_key
Configuration
# Mastodon Environment Variables
LOCAL_DOMAIN=domain.com
SECRET_KEY_BASE=generate_a_secret_key
OTP_SECRET=generate_an_otp_secret
VAPID_PRIVATE_KEY=generate_vapid_private_key
VAPID_PUBLIC_KEY=generate_vapid_public_key
DB_HOST=db
DB_USER=mastodon
DB_NAME=mastodon_production
DB_PASS=mastodon_password
REDIS_HOST=redis
# SMTP Configuration
SMTP_SERVER=smtp.your-email-provider.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=your-email-password
SMTP_FROM_ADDRESS=Mastodon <[email protected]>
Start Mastodon
docker-compose up -d