captainVersion: 4

services:
    $$cap_appname:
        image: cortezaproject/corteza:$$corteza_version
        restart: always
        depends_on:
            - $$cap_appname-db
        volumes:
            - $$cap_appname-data:/data
        environment:
            VIRTUAL_HOST: $$cap_appname.$$cap_root_domain
            DB_DSN: postgres://$$cap_postgre_username:$$cap_postgre_password@srv-captain--$$cap_appname-db:5432/$$cap_postgre_db_name?sslmode=disable
            HTTP_WEBAPP_ENABLED: true
            DOMAIN: $$cap_appname.$$cap_root_domain
            VERSION: $$corteza_version
            LETSENCRYPT_HOST: $$cap_lets_encrypt
    $$cap_appname-db:
        image: postgres:13
        restart: always
        caproverExtra:
            notExposeAsWebApp: 'true'
        volumes:
            - $$cap_appname-postgres-data:/var/lib/postgresql/data
        environment:
            POSTGRES_USER: $$cap_postgre_username
            POSTGRES_PASSWORD: $$cap_postgre_password
            POSTGRES_DB: $$cap_postgre_db_name

caproverOneClickApp:
    variables:
        - id: '$$corteza_version'
          label: Corteza Version
          defaultValue: '2021.9.5'
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/cortezaproject/corteza/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_postgre_db_name
          label: PostgreSQL Database name
          description: ''
          defaultValue: 'corteza'
          validRegex: /.{1,}/
        - id: $$cap_postgre_username
          label: PostgreSQL username
          defaultValue: 'cortezaUser'
          description: ''
          validRegex: /.{1,}/
        - id: $$cap_postgre_password
          label: PostgreSQL Password
          description: ''
          defaultValue: $$cap_gen_random_hex(16)
          validRegex: /.{1,}/
        - id: $$cap_lets_encrypt
          defaultValue: $$cap_appname.$$cap_root_domain
          label: Lets Encrypt Host for SSL.
          description: 'Set your root domain if you are going to use SSL (https://). Leave empty otherwise.'

    instructions:
        start: |-
            Corteza is an open-source, self-hosted cloud-based platform for your work. It provides a wide ecosystem of a Unified Workspace (like Google G Suite), Enterprise Messaging (like Slack), a Low-Code environment for rapidly and securely delivering records-based management solutions, and CRM and Service Solution (like Salesforce).
            For more info visit https://cortezaproject.org/

        end: |-
            Corteza has been successfully deployed!
            --------------------------------------------
            Before you proceed, please enable Websocket Support
            https://captain.$$cap_root_domain/#/apps/details/$$cap_appname
            --------------------------------------------
            App is available as http://$$cap_appname.$$cap_root_domain
    displayName: Corteza
    isOfficial: true
    description: Corteza is a free, open-source, Low Code platform for building your organisation key applications, growing its productivity and protecting its data and the privacy of all those concerned.
    documentation: This docker-compose is taken https://github.com/cortezaproject
