Files
umbrel-apps/mastodon/docker-compose.yml
T
2026-12-01 14:00:21 +10:00

130 lines
4.1 KiB
YAML

x-mastodon-image: &mastodon_image ghcr.io/mastodon/mastodon:v4.7.6@sha256:8d46d6d8ac86f16f00a8944e3ba8cd8d1e3de23b33a59354c751e071b58e18a9
x-mastodon-streaming-image: &mastodon_streaming_image ghcr.io/mastodon/mastodon-streaming:v4.7.6@sha256:5b95d22c22f1d101fd2eb5dac62ad0ca2a93a5b60e410dc071ae645e98cc73e6
x-mastodon-environment: &mastodon_environment
DB_HOST: db
DB_PASS: ${APP_MASTODON_DB_PASSWORD}
REDIS_HOST: redis
REDIS_PASSWORD: ${APP_MASTODON_REDIS_PASSWORD}
SECRET_KEY_BASE: ${APP_MASTODON_SECRET_KEY_BASE}
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: ${APP_MASTODON_AR_DETERMINISTIC_KEY}
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: ${APP_MASTODON_AR_KEY_DERIVATION_SALT}
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: ${APP_MASTODON_AR_PRIMARY_KEY}
# Web push keys and the default sender address, written by hooks/pre-start
x-mastodon-env-file: &mastodon_env_file
- path: ${APP_DATA_DIR}/mastodon.env
required: false
services:
app_proxy:
environment:
APP_HOST: mastodon_proxy_1
APP_PORT: 80
# Federation, public profiles and Mastodon's own apps need the server to be public
PROXY_AUTH_ADD: "false"
proxy:
image: nginx:1.30.3-alpine3.23@sha256:0d3b80406a13a767339fbe2f41406d6c7da727ab89cf8fae399e81f780f814d1
restart: on-failure
volumes:
- ${APP_DATA_DIR}/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
web:
condition: service_started
streaming:
condition: service_started
web:
image: *mastodon_image
user: "991:991"
restart: on-failure
stop_grace_period: 1m
command: ["bundle", "exec", "puma", "-C", "config/puma.rb"]
env_file: *mastodon_env_file
environment:
<<: *mastodon_environment
volumes:
- ${APP_DATA_DIR}/data/system:/mastodon/public/system
depends_on:
migrate:
condition: service_completed_successfully
streaming:
image: *mastodon_streaming_image
user: "991:991"
restart: on-failure
init: true
stop_grace_period: 1m
env_file: *mastodon_env_file
environment:
<<: *mastodon_environment
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
sidekiq:
image: *mastodon_image
user: "991:991"
restart: on-failure
stop_grace_period: 1m
command: ["bundle", "exec", "sidekiq"]
env_file: *mastodon_env_file
environment:
<<: *mastodon_environment
volumes:
- ${APP_DATA_DIR}/data/system:/mastodon/public/system
depends_on:
migrate:
condition: service_completed_successfully
# Creates the database and the owner account on first start, and runs
# Mastodon's database migrations after updates
migrate:
image: *mastodon_image
user: "991:991"
restart: on-failure
command: ["bundle", "exec", "rails", "db:prepare"]
env_file: *mastodon_env_file
environment:
<<: *mastodon_environment
UMBREL_OWNER_PASSWORD: ${APP_PASSWORD}
volumes:
- ${APP_DATA_DIR}/umbrel-owner.rb:/mastodon/db/seeds/99_umbrel_owner.rb:ro
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
db:
image: postgres:17.12-alpine@sha256:f9cf3e1f0066f0eb0c48707d864f0ac5941e9ff454a072077d97a4d278d07d73
user: "1000:1000"
restart: on-failure
environment:
POSTGRES_USER: mastodon
POSTGRES_PASSWORD: ${APP_MASTODON_DB_PASSWORD}
POSTGRES_DB: mastodon_production
volumes:
- ${APP_DATA_DIR}/data/db:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U mastodon -d mastodon_production"]
interval: 10s
timeout: 5s
retries: 10
redis:
image: redis:8.4.8-alpine@sha256:ff72f74e4f471df79ed920aa8bbc35efe72ff8a1f8acdc50aad5dbb9b14a4034
user: "1000:1000"
restart: on-failure
command: ["redis-server", "--save", "60", "1", "--loglevel", "warning", "--requirepass", "${APP_MASTODON_REDIS_PASSWORD}"]
volumes:
- ${APP_DATA_DIR}/data/redis:/data
healthcheck:
test: ["CMD-SHELL", "redis-cli --no-auth-warning -a ${APP_MASTODON_REDIS_PASSWORD} ping | grep PONG"]
interval: 10s
timeout: 5s
retries: 10