captainVersion: 4

services:
    # YAGPDB
    $$cap_appname:
        depends_on:
            - $$cap_appname-redis
            - $$cap_appname-postgres
        environment:
            YAGPDB_OWNER: $$cap_yagpdb_bot_owner
            YAGPDB_CLIENTID: $$cap_yagpdb_bot_client_id
            YAGPDB_CLIENTSECRET: $$cap_yagpdb_bot_client_secret
            YAGPDB_BOTTOKEN: Bot $$cap_yagpdb_bot_token
            YAGPDB_HOST: $$cap_appname.$$cap_root_domain
            YAGPDB_PQHOST: srv-captain--$$cap_appname-postgres
            YAGPDB_PQUSERNAME: yagpdb
            YAGPDB_PQDB: yagpdb_production
            YAGPDB_PQPASSWORD: $$cap_postgres_password
            YAGPDB_REDIS: srv-captain--$$cap_appname-redis:6379
        volumes:
            - $$cap_appname-soundboard:/app/soundboard
        caproverExtra:
            dockerfileLines:
                - FROM teyker/yagpdb:$$cap_yagpdb_version
                - CMD ["/app/yagpdb", "-all", "-pa", "-exthttps=true", "-https=false"]
    # Redis
    $$cap_appname-redis:
        image: redis:6.2.5-alpine
        volumes:
            - $$cap_appname-redis-data:/data
        caproverExtra:
            notExposeAsWebApp: 'true'

    # PostgreSQL
    $$cap_appname-postgres:
        image: postgres:12-alpine
        environment:
            POSTGRES_USER: yagpdb
            POSTGRES_DB: yagpdb_production
            POSTGRES_PASSWORD: $$cap_postgres_password
        volumes:
            - $$cap_appname-db-data:/var/lib/postgresql/data
        caproverExtra:
            notExposeAsWebApp: 'true'

caproverOneClickApp:
    variables:
        - id: $$cap_yagpdb_version
          label: Yagpdb Version
          defaultValue: 'v1.28.0'
          description: Checkout their docker page for the valid tags https://hub.docker.com/r/teyker/yagpdb/tags

        - id: $$cap_postgres_password
          defaultValue: $$cap_gen_random_hex(12)
          label: Postgres Password
          description: Password must be at least 12 characters. Please use a random string.
          validRegex: /^[^\@]{12,}$/

        - id: $$cap_yagpdb_bot_owner
          defaultValue: Insert your server owner id here
          label: Discord server owner ID
          description: https://support.discordapp.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-

        - id: $$cap_yagpdb_bot_client_id
          defaultValue: Insert bot OAuth2 client id here
          label: Discord bot OAuth2 client ID
          description: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token

        - id: $$cap_yagpdb_bot_client_secret
          defaultValue: Insert bot OAuth2 client secret here
          label: Discord bot OAuth2 client secret
          description: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token

        - id: $$cap_yagpdb_bot_token
          defaultValue: Insert bot token here
          label: Discord bot token
          description: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token
    instructions:
        start: >-
            Yet another general purpose discord bot.

            This is the best opensource discord bot ever made!
        end: >-
            Aaaand you're done! 😄
            Your service is available at http://$$cap_appname.$$cap_root_domain
    displayName: Yagpdb
    isOfficial: false
    description: Yet another general purpose discord bot
    documentation: Taken from https://yagpdb.xyz/
