# Mastodon - Social network
# Port: 3000
# Decentralized social media

version: "3.9"
services:
  mastodon-redis:
    image: redis
    container_name: Mastodon-REDIS
    hostname: mastodon-redis
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    user: 1026:100
    environment:
      - TZ=America/Los_Angeles
    volumes:
      - /volume1/docker/mastodon/redis:/data
    restart: unless-stopped

  mastodon-db:
    image: postgres
    container_name: Mastodon-DB
    hostname: mastodon-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "mastodon", "-U", "mastodonuser"]
      timeout: 45s
      interval: 10s
      retries: 10
    user: 1026:100
    volumes:
      - /volume1/docker/mastodon/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: mastodon
      POSTGRES_USER: mastodonuser
      POSTGRES_PASSWORD: "REDACTED_PASSWORD"  # pragma: allowlist secret
    restart: unless-stopped

  mastodon:
    image: lscr.io/linuxserver/mastodon:latest
    container_name: Mastodon
    hostname: mastodon
    security_opt:
      - no-new-privileges:true
    environment:
      - PUID=1026
      - PGID=100
      - TZ=America/Los_Angeles
      - DEFAULT_LOCALE=en
      - LOCAL_DOMAIN=mastodon.vish.gg
      - WEB_DOMAIN=mastodon.vish.gg
      - REDIS_HOST=mastodon-redis
      - REDIS_PORT=6379
      - DB_HOST=mastodon-db
      - DB_USER=mastodonuser
      - DB_NAME=mastodon
      - DB_PASS="REDACTED_PASSWORD"  # pragma: allowlist secret
      - DB_PORT=5432
      - ES_ENABLED=false
      - ES_HOST=es
      - ES_PORT=9200
      - ES_USER=elastic
      - ES_PASS="REDACTED_PASSWORD"  # pragma: allowlist secret
      - SECRET_KEY_BASE="REDACTED_SECRET_KEY_BASE"_GITEA_TOKEN  # pragma: allowlist secret
      - OTP_SECRET="REDACTED_OTP_SECRET"_GITEA_TOKEN  # pragma: allowlist secret
      - S3_ENABLED=false
    volumes:
      - /volume1/docker/mastodon/config:/config
    ports:
      - 8562:443
    restart: unless-stopped
    depends_on:
      mastodon-redis:
        condition: service_healthy
      mastodon-db:
        condition: service_started
