captainVersion: 4
services:
    $$cap_appname-db:
        image: mariadb:10.3
        environment:
            MYSQL_ROOT_PASSWORD: $$cap_db_root_pass
            MYSQL_DATABASE: passbolt_oca
            MYSQL_USER: $$cap_db_user
            MYSQL_PASSWORD: $$cap_db_pass
        volumes:
            - $$cap_appname-db:/var/lib/mysql
    $$cap_appname-pb:
        image: passbolt/passbolt:2.12.1-debian
        depends_on:
            - $$cap_appname-db
        environment:
            DATASOURCES_DEFAULT_HOST: srv-captain--$$cap_appname-db:3306
            DATASOURCES_DEFAULT_DATABASE: passbolt_oca
            DATASOURCES_DEFAULT_USERNAME: $$cap_db_user
            DATASOURCES_DEFAULT_PASSWORD: $$cap_db_pass
            APP_FULL_BASE_URL: $$cap_url
            EMAIL_TRANSPORT_DEFAULT_HOST: $$cap_email_host
            EMAIL_TRANSPORT_DEFAULT_PORT: $$cap_email_port
            EMAIL_TRANSPORT_DEFAULT_USERNAME: $$cap_email_user
            EMAIL_DEFAULT_FROM: $$cap_email_user
            EMAIL_TRANSPORT_DEFAULT_PASSWORD: $$cap_email_pass
            EMAIL_TRANSPORT_DEFAULT_TLS: $$cap_email_tls
        volumes:
            - $$cap_appname-gpg:/var/www/passbolt/config/gpg
            - $$cap_appname-images:/var/www/passbolt/webroot/img/public
caproverOneClickApp:
    variables:
        - id: $$cap_db_root_pass
          label: Database Root Password
          defaultValue: rootpassword
        - id: $$cap_db_user
          label: Database Username
          defaultValue: passbolt
        - id: $$cap_db_pass
          label: Database Password
          defaultValue: password
        - id: $$cap_pb_version
          label: Passbolt Version
          defaultValue: 2.12.1-debian
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/passbolt/passbolt/tags/
        - id: $$cap_url
          label: Passbolt URL
          description: "This is VERY IMPORTANT, if you won't use a custom domain (ex: km.yourdomain.com), after deployed you will need to go into the App Configs and update the ENV APP_FULL_BASE_URL with the external URL that CapRover assigned to your App, otherwhise it won't work"
          defaultValue: https://yourdomain.com
        - id: $$cap_email_host
          label: Email SMTP Server
          description: 'Host used as smtp server. More info: https://help.passbolt.com/configure/email/setup.'
          defaultValue: smtp.gmail.com
        - id: $$cap_email_port
          label: Email SMTP Port
          description: 'Port used with the smtp server. More info: https://help.passbolt.com/configure/email/setup'
          defaultValue: '587'
        - id: $$cap_email_user
          label: Email Username
          defaultValue: user@gmail.com
        - id: $$cap_email_pass
          label: Email Password
          defaultValue: password
        - id: $$cap_email_tls
          label: TLS Enabled
          defaultValue: 'true'
    instructions:
        start: >-
            Passbolt is a free and open source password manager that allows team members to store and share credentials securely.

            Enter your Passbolt configuration parameters and click on next. A MariaDB (database) and a Passbolt container will be created for you.  The process will take about a minute for the process to finish.
        end: >-
            Passbolt is deployed and available as $$cap_appname-pb . 

            IMPORTANT: It will take up to 2 minutes for Passbolt to be ready. Before that, you might see a 502 error page.

            Note: Once the container is running create your first admin user running the following command in the terminal:


            $ docker exec <containerID> su -m -c '/var/www/passbolt/bin/cake passbolt register_user -u your@email.com -f yourname -l surname -r admin' -s /bin/sh www-data


            This registration command will return a single use url required to continue the web browser setup and finish the registration. Your passbolt instance should be available browsing https://yourdomain.com
    displayName: Passbolt
    isOfficial: true
    description: Passbolt is a free and open source password manager that allows team members to store and share credentials securely.
    documentation: Taken from https://hub.docker.com/r/passbolt/passbolt.
