{
    "captainVersion": "2",
    "documentation": "Taken from https://github.com/Mailtrain-org/mailtrain/blob/development/docker-compose.yml",
    "displayName": "Mailtrain V2(Beta)",
    "description": "Mailtrain is a self hosted newsletter application built on Node.js (v10+) and MySQL (v8+) or MariaDB (v10+).",
    "dockerCompose": {
        "version": "3.8",
        "services": {
            "$$cap_appname-db": {
                "image": "mariadb:$$cap_mariadb_version",
                "notExposeAsWebApp": "true",
                "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"
                }
            },
            "$$cap_appname-redis": {
                "notExposeAsWebApp": "true",
                "image": "redis:$$cap_redis_version",
                "volumes": ["$$cap_appname-redis-data:/data"],
                "restart": "always"
            },
            "$$cap_appname-mongo": {
                "notExposeAsWebApp": "true",
                "image": "mongo:$$cap_mongo_version",
                "volumes": ["$$cap_appname-mongo-data:/data/db"],
                "restart": "always"
            },
            "$$cap_appname": {
                "image": "mailtrain/mailtrain:$$cap_mailtrain_version",
                "containerHttpPort": "3000",
                "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"
                }
            },
            "$$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"
                }
            }
        },
        "volumes": {
            "$$cap_appname-db-data": {},
            "$$cap_appname-redis-data": {},
            "$$cap_appname-mongo-data": {},
            "$$cap_appname-files": {}
        }
    },
    "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."
    },
    "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,}$/"
        }
    ]
}
