captainVersion: 4
services:
    $$cap_appname-postgresql:
        documentation: Taken from https://hub.docker.com/r/bitnami/postgresql
        image: docker.io/bitnami/postgresql:$$cap_postgresql_version
        restart: always
        environment:
            ALLOW_EMPTY_PASSWORD: yes
        volumes:
            - $$cap_appname-postgresql-data:/bitnami/postgresql
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-redis:
        documentation: Taken from https://hub.docker.com/r/bitnami/redis
        image: docker.io/bitnami/redis:$$cap_redis_version
        restart: always
        environment:
            ALLOW_EMPTY_PASSWORD: yes
        volumes:
            - $$cap_appname-redis-data:/bitnami
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        documentation: Taken from https://hub.docker.com/r/bitnami/discourse
        image: docker.io/bitnami/discourse:$$cap_discourse_version
        depends_on:
            - $$cap_appname-postgresql
            - $$cap_appname-redis
        volumes:
            - $$cap_appname-data:/bitnami
        environment:
            POSTGRESQL_HOST: srv-captain--$$cap_appname-postgresql
            POSTGRESQL_ROOT_USER: postgres
            POSTGRESQL_CLIENT_CREATE_DATABASE_NAME: $$cap_db_name
            POSTGRESQL_CLIENT_CREATE_DATABASE_USERNAME: $$cap_db_user
            POSTGRESQL_CLIENT_CREATE_DATABASE_PASSWORD: $$cap_db_pass
            DISCOURSE_USERNAME: $$cap_admin_user
            DISCOURSE_PASSWORD: $$cap_admin_pass
            DISCOURSE_EMAIL: $$cap_admin_email
            DISCOURSE_SITENAME: $$cap_sitename
            DISCOURSE_POSTGRESQL_NAME: $$cap_db_name
            DISCOURSE_POSTGRESQL_USERNAME: $$cap_db_user
            DISCOURSE_POSTGRESQL_PASSWORD: $$cap_db_pass
            DISCOURSE_HOSTNAME: $$cap_appname.$$cap_root_domain
            REDIS_HOST: srv-captain--$$cap_appname-redis
            SMTP_HOST: $$cap_smtp_host
            SMTP_PORT: $$cap_smtp_port
            SMTP_USER: $$cap_smtp_user
            SMTP_PASSWORD: $$cap_smtp_pass
        caproverExtra:
            containerHttpPort: '3000'
    $$cap_appname-sidekiq:
        documentaion: Taken from https://hub.docker.com/r/bitnami/discourse
        depends_on:
            - $$cap_appname
        volumes:
            - $$cap_appname-data:/bitnami
        environment:
            DISCOURSE_POSTGRESQL_NAME: $$cap_db_name
            DISCOURSE_POSTGRESQL_USERNAME: $$cap_db_user
            DISCOURSE_POSTGRESQL_PASSWORD: $$cap_db_pass
            DISCOURSE_HOST: srv-captain--$$cap_appname
            DISCOURSE_PORT: '3000'
            DISCOURSE_HOSTNAME: $$cap_appname.$$cap_root_domain
            POSTGRESQL_HOST: srv-captain--$$cap_appname-postgresql
            REDIS_HOST: srv-captain--$$cap_appname-redis
            SMTP_HOST: $$cap_smtp_host
            SMTP_PORT: $$cap_smtp_port
            SMTP_USER: $$cap_smtp_user
            SMTP_PASSWORD: $$cap_smtp_pass
        caproverExtra:
            dockerfileLines:
                - FROM docker.io/bitnami/discourse:$$cap_discourse_version
                - CMD ["nami" , "start" , "--foreground" , "discourse-sidekiq"]
            notExposeAsWebApp: 'true'
caproverOneClickApp:
    variables:
        - id: $$cap_discourse_version
          label: Discourse Version
          defaultValue: 2.4.4
          description: Version of Discourse
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_postgresql_version
          label: Postgresql (database) version
          defaultValue: '11'
          description: Version of Postgresql
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_sitename
          label: Sitename
          defaultValue: My site!
          description: The title of the site, the words on the tab
        - id: $$cap_redis_version
          label: Redis version
          defaultValue: '5.0'
          description: Version of Redis
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_admin_user
          label: Admin username
          defaultValue: admin
          description: Name of the admin account
          validRegex: /.{1,}/
        - id: $$cap_admin_pass
          label: Admin password
          defaultValue: sTr0nG_p@s$wo%d
          description: Password of the admin account
          validRegex: /.{1,}/
        - id: $$cap_admin_email
          label: Admin email
          defaultValue: your_email@gmail.com
          description: Email of the admin account
          validRegex: /.{1,}/
        - id: $$cap_db_name
          label: Database name
          defaultValue: discourse_db
          description: Name for the database using postgresql
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_db_user
          label: Database user
          defaultValue: discourse_user
          description: Username for the database using postgresql
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_db_pass
          label: Database password
          defaultValue: sTr0nG_p@s$wo%d
          description: Password for the database user and root using postgresql
          validRegex: /.{1,}/
        - id: $$cap_smtp_host
          label: SMPT host
          defaultValue: smtp.gmail.com
          description: The host for your smtp server
        - id: $$cap_smtp_port
          label: SMTP port
          defaultValue: '587'
          description: The port for your smtp server
        - id: $$cap_smtp_user
          label: SMTP user
          defaultValue: your_email@gmail.com
          description: The user for your smtp server
        - id: $$cap_smtp_pass
          label: SMTP password
          defaultValue: sTr0nG_p@s$wo%d
          description: The password for your smtp server
    instructions:
        start: Discourse is a relatively heavy application, atleast 2GB RAM is recommended to run Discourse
        end: Discourse image is deployed and the installation process has begun. The installation process takes about 10 minutes.
    displayName: Discourse
    isOfficial: true
    description: Discourse is the 100% open source discussion platform built for the next decade of the Internet. Use it as a mailing list, discussion forum, long-form chat room, and more!
    documentation: Taken from https://hub.docker.com/r/bitnami/discourse
