captainVersion: 4
services:
    $$cap_appname:
        image: influxdb:$$cap_influx_version
        volumes:
            - $$cap_appname-data:/var/lib/influxdb2
            - $$cap_appname-configs:/etc/influxdb2
        environment:
            DOCKER_INFLUXDB_INIT_USERNAME: $$cap_influx_init_username
            DOCKER_INFLUXDB_INIT_PASSWORD: $$cap_influx_init_password
            DOCKER_INFLUXDB_INIT_ORG: $$cap_influx_init_org
            DOCKER_INFLUXDB_INIT_BUCKET: $$cap_influx_bucket
            DOCKER_INFLUXDB_INIT_RETENTION: $$cap_influx_retention
            DOCKER_INFLUXDB_INIT_MODE: setup
            DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: $$cap_influx_token
        caproverExtra:
            containerHttpPort: '8086'
caproverOneClickApp:
    variables:
        - id: $$cap_influx_version
          label: InfluxDb Version
          defaultValue: '2.0'
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/library/influxdb/tags/
          validRegex: /^([^\s^\/])+$/
        - label: Influx Bucket
          description: Automatically initializes a database with this bucket ID.
          defaultValue: 'my-bucket'
          id: $$cap_influx_bucket
        - label: Username for initialization
          defaultValue: 'username'
          id: $$cap_influx_init_username
        - label: Password for initialization
          defaultValue: $$cap_gen_random_hex(12)
          id: $$cap_influx_init_password
        - label: Admin Access Token
          defaultValue: $$cap_gen_random_hex(24)
          id: $$cap_influx_token
        - label: Organization for intialization
          defaultValue: 'my-org'
          id: $$cap_influx_init_org
        - label: Retention for data
          description: The duration the system's initial bucket should retain data. If not set, the initial bucket will retain data forever.
          defaultValue: '52w'
          id: $$cap_influx_retention
    instructions:
        start: >-
            Influxdb2 is a time series database, and part of the tickstack. After installation on CapRover, it will be available as srv-captain--YOUR_CONTAINER_NAME to other CapRover apps.

            Enter your Influxdb configuration parameters and click on next. The default configuration has no users or authentication and is only accessible to other Caprover apps. It will take about a minute for the process to finish.
        end: >-
            All set. Influx is deployed and available as srv-captain--$$cap_appname:8086 to other apps. Externally you can access it via HTTP like a regular app. Make sure you enable SSL.
    displayName: InfluxDb2
    isOfficial: true
    description: InfluxDB2 is a time series database. It stores large amounts of timestamped data, including DevOps monitoring, application metrics, IoT sensor data, and real-time analytics.
    documentation: Taken from https://hub.docker.com/_/influxdb
