captainVersion: 4

services:
    $$cap_appname-db:
        image: postgres:$$cap_postgres_version
        volumes:
            - $$cap_appname-db-data:/var/lib/postgresql/data
        restart: always
        environment:
            POSTGRES_USER: $$cap_postgres_username
            POSTGRES_PASSWORD: $$cap_postgres_password
            POSTGRES_DB: $$cap_postgres_db_name
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        environment:
            TZ: Etc/UTC
            LISTMONK_db__host: srv-captain--$$cap_appname-db
            LISTMONK_db__database: $$cap_postgres_db_name
            LISTMONK_db__user: $$cap_postgres_username
            LISTMONK_db__password: $$cap_postgres_password
            LISTMONK_db__ssl_mode: $$cap_postgres_ssl_mode
            LISTMONK_app__admin_username: $$cap_listmonk_admin_username
            LISTMONK_app__admin_password: $$cap_listmonk_admin_password
            LISTMONK_app__address: 0.0.0.0:9000
        caproverExtra:
            containerHttpPort: 9000
            dockerfileLines:
                - FROM listmonk/listmonk:$$cap_listmonk_version
                - CMD yes | ./listmonk --install && ./listmonk
        volumes:
            - $$cap_appname-data:/listmonk
        depends_on:
            - $$cap_appname-db

caproverOneClickApp:
    variables:
        - id: $$cap_postgres_version
          label: Postgresql Version
          defaultValue: '14.1'
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/postgres?tab=tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_listmonk_version
          label: Listmonk Version
          defaultValue: 'v2.0.0'
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/listmonk/listmonk/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_postgres_db_name
          label: PostgreSQL Database name
          defaultValue: 'listmonk'
          validRegex: /.{1,}/
        - id: $$cap_postgres_username
          label: PostgreSQL username
          defaultValue: 'listmonk'
          validRegex: /.{1,}/
        - id: $$cap_postgres_password
          label: PostgreSQL Password
          defaultValue: $$cap_gen_random_hex(32)
          validRegex: /.{1,}/
        - id: $$cap_postgres_ssl_mode
          label: PostgreSQL SSL Mode
          defaultValue: 'disable'
          validRegex: /.{1,}/
        - id: $$cap_listmonk_admin_username
          label: Listmonk Admin Username
          defaultValue: 'listmonk'
          validRegex: /.{1,}/
        - id: $$cap_listmonk_admin_password
          label: Listmonk Admin Password
          defaultValue: $$cap_gen_random_hex(32)
          validRegex: /.{1,}/
    instructions:
        start: |-
            High performance, self-hosted newsletter and mailing list manager with a modern dashboard
        end: |-
            $$cap_appname is deployed
    displayName: Listmonk
    isOfficial: false ## Only if all images used here are official or from a trusted source.
    description: High performance, self-hosted newsletter and mailing list manager with a modern dashboard
    documentation: This docker-compose is taken https://github.com/knadh/listmonk
