Skip to main content

Installation

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: