captainVersion: 4
services:
    '$$cap_appname':
        depends_on:
            - $$cap_appname-db
        image: quay.io/hedgedoc/hedgedoc:$$cap_version
        environment:
            CMD_DB_URL: postgres://$$cap_dbuser:$$cap_dbpass@srv-captain--$$cap_appname-db:5432/$$cap_dbname
            CMD_DOMAIN: $$cap_appname.$$cap_root_domain
            CMD_URL_ADDPORT: false
            PLUGIN_INSTALLER: $$cap_plugin_installer
        volumes:
            - '$$cap_appname-uploads:/hedgedoc/public/uploads'
        caproverExtra:
            containerHttpPort: '3000'
    $$cap_appname-db:
        image: postgres:$$cap_pgversion
        volumes:
            - $$cap_appname-db:/var/lib/postgresql/data
        restart: always
        environment:
            POSTGRES_DB: $$cap_dbname
            POSTGRES_USER: $$cap_dbuser
            POSTGRES_PASSWORD: $$cap_dbpass
        caproverExtra:
            notExposeAsWebApp: 'true'

caproverOneClickApp:
    variables:
        # app variables
        - id: '$$cap_version'
          label: HedgeDoc Version
          defaultValue: '1.7.2'
          description: Make sure to use the latest release from https://hedgedoc.org/latest-release
          validRegex: '/^([^\\s^\\/])+$/'
          # db variables
        - id: '$$cap_pgversion'
          label: Postgresql Version
          defaultValue: '9.6-alpine'
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/library/postgres/tags/
          validRegex: '/^([^\\s^\\/])+$/'
        - id: $$cap_dbname
          label: Database Name
          defaultValue: 'joplin'
          validRegex: /.{1,}/
        - id: $$cap_dbuser
          label: Database User
          defaultValue: 'joplin'
          validRegex: /.{1,}/
        - id: $$cap_dbpass
          label: Database Password
          defaultValue: $$cap_gen_random_hex(64)
          validRegex: /.{10,}/
    instructions:
        start: |-
            HedgeDoc lets you create real-time collaborative markdown notes. For more info visit https://docs.hedgedoc.org/
        end: |-
            HedgeDoc has been successfully deployed!
            App is available as http://$$cap_appname.$$cap_root_domain
    displayName: HedgeDoc
    isOfficial: true
    description: HedgeDoc lets you create real-time collaborative markdown notes
    documentation: See https://docs.hedgedoc.org/
