captainVersion: 4
services:
    # Statping
    $$cap_appname:
        depends_on:
            - $$cap_appname-postgres
        image: statping/statping:$$cap_statping_version
        volumes:
            - $$cap_appname-app:/app
        environment:
            ADMIN_USER: $$cap_admin_user
            ADMIN_PASSWORD: $$cap_admin_pass
            ADMIN_EMAIL: $$cap_admin_email
            DB_CONN: postgres
            DB_HOST: srv-captain--$$cap_appname-postgres
            DB_USER: $$cap_db_user
            DB_PASS: $$cap_db_pass
            DB_DATABASE: $$cap_db_name
        caproverExtra:
            containerHttpPort: '8080'
    # PostgreSQL
    $$cap_appname-postgres:
        image: postgres:13-alpine
        environment:
            POSTGRES_USER: $$cap_db_user
            POSTGRES_PASSWORD: $$cap_db_pass
            POSTGRES_DB: $$cap_db_name
        volumes:
            - $$cap_appname-postgres-data:/var/lib/postgresql/data
        caproverExtra:
            notExposeAsWebApp: 'true'
caproverOneClickApp:
    variables:
        - id: $$cap_statping_version
          label: Statping Version
          defaultValue: 'v0.90.74'
          description: Check out their docker page for the valid tags https://hub.docker.com/r/statping/statping/tags
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_db_user
          label: Database user
          description: Database username
          defaultValue: statping
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_db_name
          label: Database name
          description: Database name
          defaultValue: statping
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_db_pass
          label: Database Password
          description: Password to connect to the database
          defaultValue: $$cap_gen_random_hex(16)
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_admin_user
          label: Statping Admin
          description: Username to access the statping dashboard
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_admin_pass
          label: Statping Admin Password
          description: Password to access the statping dashboard
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_admin_email
          label: Statping Admin Email
          validRegex: /^([^\s^\/])+$/

    instructions:
        start: >-
            Statping - Web and App Status Monitoring for Any Type of Project.
        end: >-
            Aaaand you're done! 😄


            Your service is available at http://$$cap_appname.$$cap_root_domain


            For more environment variables pls see https://github.com/statping/statping/wiki/Environment-Variables
    displayName: 'Statping'
    isOfficial: true
    description: Statping - Web and App Status Monitoring for Any Type of Project.
    documentation: Taken from https://github.com/statping/statping
