captainVersion: 4
services:
    $$cap_appname-postgres:
        image: postgres@$$cap_postgres_version
        volumes:
            - $$cap_appname-postgres-data:/var/lib/postgresql/data
        restart: always
        environment:
            POSTGRES_USER: mattermost
            POSTGRES_PASSWORD: $$cap_pg_pass
            POSTGRES_DB: mattermost
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        depends_on:
            - $$cap_appname-postgres
        volumes:
            - $$cap_appname-data:/mattermost/data
            - $$cap_appname-logs:/mattermost/logs
            - $$cap_appname-config:/mattermost/config
            - $$cap_appname-plugins:/mattermost/plugins
            - $$cap_appname-clientplugins:/mattermost/client/plugins
        restart: always
        environment:
            MM_SQLSETTINGS_DATASOURCE: postgres://mattermost:$$cap_pg_pass@srv-captain--$$cap_appname-postgres:5432/mattermost?sslmode=disable&connect_timeout=10
            MM_SERVICESETTINGS_SITEURL: https://$$cap_appname.$$cap_root_domain
            MM_LOGSETTINGS_ENABLEDIAGNOSTICS: 'false'
            MM_SERVICESETTINGS_ENABLESECURITYFIXALERT: 'false'
            MM_SQLSETTINGS_DRIVERNAME: postgres
        caproverExtra:
            containerHttpPort: '8065'
            dockerfileLines:
                - FROM mattermost/mattermost-team-edition@$$cap_mattermost_version
                - RUN sed -i 's#api.segment.io#xx.example.com#gI' /mattermost/bin/mattermost
                - RUN sed -i 's#securityupdatecheck.mattermost.com#xxxxxxxxxxxxxxxxxxxxxx.example.com#gI' /mattermost/bin/mattermost
caproverOneClickApp:
    variables:
        - id: $$cap_postgres_version
          label: Postgres Docker Image SHA Hash
          defaultValue: sha256:110d3325db02daa6e1541fdd37725fcbecb7d51411229d922562f208c51d35cc
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/library/postgres/tags/ - default is 12.2 as of 2020-03-16
        - id: $$cap_mattermost_version
          label: Mattermost Docker Image SHA Hash
          defaultValue: sha256:f8a4416d0a50a03ebacdbcd44790d5996230da3f48dbefd02307e4fd713567aa
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/mattermost/mattermost-team-edition/tags - default is current as of 2020-03-16
        - id: $$cap_pg_pass
          label: Postgres Password
          description: Password must be at least 30 characters.  Please use a random string.
          validRegex: /^[^\@]{30,}$/
    instructions:
        start: Open-source collaboration/chat server Mattermost Team Edition.
        end: Mattermost is deployed and available as srv-captain--$$cap_appname:80.  Note that the application may take up to ten minutes to become available.  Following deployment you must verify MM_SERVICESETTINGS_SITEURL in the application's environment refers to your app's official public URL.
    displayName: Mattermost
    isOfficial: true
    description: Mattermost Team Edition open source collaboration/chat software
    documentation: https://github.com/mattermost/mattermost-docker
