captainVersion: 4
services:
    $$cap_appname-redis:
        image: redis
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-mongo:
        image: mongo
        volumes:
            - $$cap_appname-mongo-data:/data/db
        environment:
            MONGO_INITDB_ROOT_USERNAME: $$cap_db_user
            MONGO_INITDB_ROOT_PASSWORD: $$cap_db_pass
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-mailhog:
        image: mailhog/mailhog
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-api:
        image: ohmyform/api
        environment:
            CREATE_ADMIN: true
            ADMIN_EMAIL: $$cap_ohmyform_email
            ADMIN_USERNAME: $$cap_ohmyform_user
            ADMIN_PASSWORD: $$cap_ohmyform_pass
            MONGODB_URI: mongodb://$$cap_db_user:$$cap_db_pass@srv-captain--$$cap_appname-mongo:27017/$$cap_appname?authSource=admin
            MAILER_URI: smtp://srv-captain--$$cap_appname-mailhog:1025
            REDIS_URL: redis://$$cap_appname-redis
            SECRET_KEY: $$cap_gen_random_hex(64)
            PORT: 5000
        caproverExtra:
            containerHttpPort: '5000'
    $$cap_appname:
        image: ohmyform/ui
        environment:
            API_HOST: https://$$cap_appname-api.$$cap_root_domain/graphql
            HIDE_CONTRIB: true
            APP_NAME: $$cap_ohmyform_title
            PORT: 5000
        caproverExtra:
            containerHttpPort: '5000'
caproverOneClickApp:
    variables:
        - id: $$cap_ohmyform_email
          label: Admin E-Mail
          description: E-Mail for the OhMyForm admin user
          validRegex: /.{1,}/
        - id: $$cap_ohmyform_user
          label: Admin user name
          description: User name for the OhMyForm admin user
          defaultValue: ohmyadmin
          validRegex: /.{1,}/
        - id: $$cap_ohmyform_pass
          label: Admin password
          description: Password for the OhMyForm admin user
          defaultValue: $$cap_gen_random_hex(64)
          validRegex: /.{1,}/
        - id: $$cap_db_user
          label: Database user
          defaultValue: ohmyform
          validRegex: /^([a-zA-Z0-9])+$/
        - id: $$cap_db_pass
          label: Database password
          defaultValue: $$cap_gen_random_hex(64)
          validRegex: /.{1,}/
        - id: $$cap_ohmyform_title
          label: Title
          description: Title for OhMyForm
          defaultValue: OhMyForm
          validRegex: /.{1,}/
    instructions:
        start: |-
            An open source alternative to TypeForm and Google Forms that can create stunning mobile-ready forms, surveys and questionnaires.
            With OhMyForm you'll get all the features you need to run, administer, analyze and distribute forms for free.
            More details: https://ohmyform.com/
        end: |-
            OhMyForm has been successfully deployed! Be sure to activate (or better yet, enforce) https access for $$cap_appname-api and $$cap_appname. You can then log in with user $$cap_ohmyform_user and password $$cap_ohmyform_pass at https://$$cap_appname.$$cap_root_domain
    displayName: OhMyForm
    isOfficial: true
    description: Create stunning embedable forms for recruiting, market research, surveys and more https://ohmyform.com/
    documentation: https://ohmyform.com/docs/
