version: "3.9"

services:
  db:
    image: postgres:${POSTGRES_IMAGE_TAG}    
    restart: ${RESTART_POLICY}
    tmpfs:
      - /tmp
      - /var/run/postgresql
    security_opt:
      - no-new-privileges:true
    networks:
      - default
    volumes:
      - {{ service_directory }}/data/db:/var/lib/postgresql/data
    environment:
      # timezone inside container
      - TZ
      # necessary Postgres options/variables
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB

  app:
    depends_on:
      - db 
    image: mattermost/${MATTERMOST_IMAGE}:${MATTERMOST_IMAGE_TAG}    
    restart: ${RESTART_POLICY}
    security_opt:
      - no-new-privileges:true
    tmpfs:
      - /tmp
    ports:
      - ${APP_PORT}:8065
      - ${CALLS_PORT}:8443/udp
    networks:
      - default
    volumes:
      - {{ service_directory }}/data/config:/mattermost/config
      - {{ service_directory }}/data/appdata:/mattermost/data
      - {{ service_directory }}/data/logs:/mattermost/logs
      - {{ service_directory }}/data/plugins:/mattermost/plugins
      - {{ service_directory }}/data/plugins_client:/mattermost/client/plugins
      - {{ service_directory }}/data/bleve_indexes:/mattermost/bleve-indexes
    environment:
      # timezone inside container
      - TZ
      - MM_SQLSETTINGS_DRIVERNAME
      - MM_SQLSETTINGS_DATASOURCE
      # necessary for bleve
      - MM_BLEVESETTINGS_INDEXDIR

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.1.0.0/16
          gateway: 172.1.0.1