# Mostlymatter from: https://framagit.org/framasoft/framateam/mostlymatter
# Don't forget to chmod +x
services:

  app:
    image: mattermost/mattermost-team-edition:11.1
    container_name: ${mattermostServName}
    restart: ${restartPolicy}
    volumes:
      - matterConfig:/mattermost/config:rw
      - matterData:/mattermost/data:rw
      - matterLogs:/mattermost/logs:rw
      - matterPlugins:/mattermost/plugins:rw
      - matterClientPlugins:/mattermost/client/plugins:rw
      - /etc/ssl:/etc/ssl:ro
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /etc/environment:/etc/environment:ro
      - ./mostlymatter-amd64-v11.1.0:/mattermost/bin/mattermost
    env_file:
      - ../../secret/env-${mattermostServName}
    environment:
      - VIRTUAL_HOST=mattermost.${domain}
      - MM_PASSWORDSETTINGS_MINIMUMLENGTH=10
      - MM_PASSWORDSETTINGS_LOWERCASE=false
      - MM_PASSWORDSETTINGS_UPPERCASE=false
      - MM_PASSWORDSETTINGS_NUMBER=false
      - MM_PASSWORDSETTINGS_SYMBOL=true
    depends_on:
      - postgres
    links:
      - postgres
    expose:
      - ${matterPort}
    networks:
      - mattermostNet
      - postfixNet
    external_links:
      - ${smtpServName}:${smtpHost}.${domain}
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${mattermostServName}.rule=Host(`${matterHost}.${domain}`)"
      - "traefik.http.services.${mattermostServName}.loadbalancer.server.port=${matterPort}"
      - "traefik.docker.network=mattermostNet"

  postgres:
    image: postgres:17-alpine
    container_name: matterPG
    restart: ${restartPolicy}
    networks:
      - mattermostNet
    security_opt:
      - no-new-privileges:true
    pids_limit: 100
    read_only: true
    tmpfs:
      - /tmp
      - /var/run/postgresql
    volumes:
      - matterPG:/var/lib/postgresql/data
#    environment:
      # timezone inside container
      # - TZ
    env_file:
      - ../../secret/env-${mattermostDBName}


volumes:
  matterPG:
  matterConfig:
  matterData:
  matterLogs:
  matterPlugins:
  matterClientPlugins:
  matterConfigLangSrv:
  matterConfigLangClt:

networks:
  mattermostNet:
    external: true
    name: mattermostNet
  postfixNet:
    external: true
    name: postfixNet
