# Mattermost - Team collaboration
# Port: 8065
# Self-hosted Slack alternative
version: "3.9"
services:
  mattermost-db:
    image: postgres
    container_name: Mattermost-DB
    hostname: mattermost-db
    security_opt:
      - no-new-privileges:true
    pids_limit: 100
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "mattermost", "-U", "mattermostuser"]
      interval: 10s
      timeout: 5s
      retries: 5
    user: 0:0
    volumes:
      - /root/docker/mattermost/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=mattermost
      - POSTGRES_USER=mattermostuser
      - POSTGRES_PASSWORD="REDACTED_PASSWORD"
      - TZ=America/Los_Angeles
    restart: unless-stopped

  mattermost:
    image: mattermost/mattermost-team-edition:latest
    container_name: Mattermost
    hostname: mattermost
    security_opt:
      - no-new-privileges:true
    pids_limit: 200
    user: 0:0
    volumes:
      - /root/docker/mattermost/config:/mattermost/config:rw
      - /root/docker/mattermost/data:/mattermost/data:rw
      - /root/docker/mattermost/logs:/mattermost/logs:rw
      - /root/docker/mattermost/plugins:/mattermost/plugins:rw
      - /root/docker/mattermost/client:/mattermost/client/plugins:rw
      - /root/docker/mattermost/indexes:/mattermost/bleve-indexes:rw
    environment:
      - TZ=America/Los_Angeles
      - MM_SQLSETTINGS_DRIVERNAME=postgres
      - MM_SQLSETTINGS_DATASOURCE=postgres://mattermostuser:mattermostpw@mattermost-db:5432/mattermost?sslmode=disable&connect_timeout=10
      - MM_BLEVESETTINGS_INDEXDIR=/mattermost/bleve-indexes
      - MM_SERVICESETTINGS_SITEURL=https://mm.vish.gg
    ports:
      - 8401:8065
    restart: unless-stopped
    depends_on:
      mattermost-db:
        condition: service_healthy
