captainVersion: 4
services:
    $$cap_appname-db:
        image: mariadb:$$cap_mariadb_version
        volumes:
            - $$cap_appname-db-data:/var/lib/mysql
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: $$cap_mariadb_password
            MYSQL_DATABASE: mailtrain
            MYSQL_USER: mailtrain
            MYSQL_PASSWORD: $$cap_mariadb_password
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-redis:
        image: redis:$$cap_redis_version
        volumes:
            - $$cap_appname-redis-data:/data
        restart: always
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-mongo:
        image: mongo:$$cap_mongo_version
        volumes:
            - $$cap_appname-mongo-data:/data/db
        restart: always
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        image: mailtrain/mailtrain:$$cap_mailtrain_version
        depends_on:
            - $$cap_appname-db
            - $$cap_appname-redis
            - $$cap_appname-mongo
        volumes:
            - $$cap_appname-files:/app/server/files
        environment:
            URL_BASE_TRUSTED: https://$$cap_appname.$$cap_root_domain
            URL_BASE_SANDBOX: https://$$cap_appname-$$cap_mailtrain_sandbox-appname.$$cap_root_domain
            URL_BASE_PUBLIC: https://$$cap_appname-$$cap_mailtrain_lists-appname.$$cap_root_domain
            WWW_PROXY: true
            MONGO_HOST: srv-captain--$$cap_appname-mongo
            REDIS_HOST: srv-captain--$$cap_appname-redis
            MYSQL_HOST: srv-captain--$$cap_appname-db
            MYSQL_PASSWORD: $$cap_mariadb_password
        caproverExtra:
            containerHttpPort: '3000'
    $$cap_appname-$$cap_mailtrain_sandbox-appname:
        image: caprover/nginx-reverse-proxy:latest
        restart: always
        depends_on:
            - $$cap_appname
        environment:
            UPSTREAM_HTTP_ADDRESS: http://srv-captain--$$cap_appname:3003
    $$cap_appname-$$cap_mailtrain_lists-appname:
        image: caprover/nginx-reverse-proxy:latest
        restart: always
        depends_on:
            - $$cap_appname
        environment:
            UPSTREAM_HTTP_ADDRESS: http://srv-captain--$$cap_appname:3004
caproverOneClickApp:
    variables:
        - id: $$cap_mariadb_version
          label: Mariadb Version
          defaultValue: 10.5.4
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/mariadb?tab=tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_mariadb_password
          label: Mariadb User password
          description: ''
          validRegex: /.{1,}/
        - id: $$cap_redis_version
          label: Redis Version
          defaultValue: alpine3.12
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/redis?tab=tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_mongo_version
          label: Mongo Version
          defaultValue: 4.4.0-rc11
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/mongo?tab=tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_mailtrain_version
          label: Mailtrain Version
          defaultValue: latest
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/mailtrain/mailtrain/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_mailtrain_sandbox-appname
          label: Sandbox Mailtrain App Name
          defaultValue: sdbx
          description: ''
          validRegex: /^[a-z]{1,}$/
        - id: $$cap_mailtrain_lists-appname
          label: Public Mailtrain App Name
          defaultValue: lists
          description: ''
          validRegex: /^[a-z]{1,}$/
    instructions:
        start: Mailtrain is a self hosted newsletter application built on Node.js (v10+) and MySQL (v8+) or MariaDB (v10+).
        end: You can connect to http://$$cap_appname.$$cap_root_domain with the user admin and password test. Do not forget to update it with something more secure.
    displayName: Mailtrain V2(Beta)
    isOfficial: true
    description: Mailtrain is a self hosted newsletter application built on Node.js (v10+) and MySQL (v8+) or MariaDB (v10+).
    documentation: Taken from https://github.com/Mailtrain-org/mailtrain/blob/development/docker-compose.yml
