captainVersion: 4
services:
    $$cap_appname-db:
        image: postgres:$$cap_pg_version
        volumes:
            - $$cap_appname-db-data:/var/lib/postgresql/data
        restart: always
        environment:
            POSTGRES_USER: $$cap_pg_user
            POSTGRES_PASSWORD: $$cap_pg_pass
            POSTGRES_DB: $$cap_pg_name
            PGDATA: /var/lib/postgresql/data

        caproverExtra:
            notExposeAsWebApp: 'true'

    $$cap_appname-redis:
        volumes:
            - $$cap_appname-redis-data:/data
        restart: always
        environment:
            REDIS_PASSWORD: $$cap_redis_password
        caproverExtra:
            dockerfileLines:
                - FROM redis:$$cap_redis_version
                - CMD exec redis-server --requirepass "$$cap_redis_password"
            notExposeAsWebApp: 'true'

    $$cap_appname:
        depends_on:
            - $$cap_appname-db
            - $$cap_appname-redis
        image: lscr.io/linuxserver/netbox:$$cap_netbox_version
        volumes:
            - $$cap_appname-data:/config
            - $$cap_appname-scripts:/app/netbox/scripts
            - $$cap_appname-reports:/app/netbox/netbox/reports
        restart: unless-stopped
        environment:
            TZ: $$cap_time_zone
            SUPERUSER_EMAIL: $$cap_superuser_email
            SUPERUSER_PASSWORD: $$cap_superuser_pass
            ALLOWED_HOST: $$cap_appname.$$cap_root_domain
            DB_NAME: $$cap_pg_name
            DB_USER: $$cap_pg_user
            DB_PASSWORD: $$cap_pg_pass
            DB_HOST: srv-captain--$$cap_appname-db
            DB_PORT: 5432
            REDIS_HOST: srv-captain--$$cap_appname-redis
            REDIS_PORT: 6379
            REDIS_PASSWORD: $$cap_redis_password
            REDIS_DB_TASK: 0
            REDIS_DB_CACHE: 1

        caproverExtra:
            containerHttpPort: '8000'

caproverOneClickApp:
    variables:
        - id: $$cap_pg_version
          label: Postgres Version Tag
          defaultValue: 12.2
          description: 'Check out the Docker page for valid tags https://hub.docker.com/r/library/postgres/tags/.'
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_pg_user
          label: Postgres Username
          defaultValue: postgres
        - id: $$cap_pg_pass
          label: Postgres Password
          defaultValue: $$cap_gen_random_hex(12)
          description: 'Password must be at least 12 characters.  Please use a random string.'
        - id: $$cap_pg_name
          label: Postgres Database
          defaultValue: netbox-pgsql
        - id: $$cap_redis_version
          label: Redis Version Tag
          description: 'Check out the Docker page for valid tags: https://hub.docker.com/_/redis?tab=tags.'
          defaultValue: 5
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_redis_password
          label: Redis Password
          validRegex: /^(\w|[^\s"])+$/
          defaultValue: $$cap_gen_random_hex(12)
        - id: $$cap_netbox_version
          label: Netbox Version Tag
          description: 'Check out the Docker page for valid tags: https://hub.docker.com/r/linuxserver/netbox/tags.'
          defaultValue: 3.1.6
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_time_zone
          label: Time Zone
          defaultValue: America/New_York
        - id: $$cap_superuser_email
          label: Email for user "admin"
          description: 'Email address for the Netbox admin account.'
          defaultValue: user@example.tld
        - id: $$cap_superuser_pass
          label: Admin Password
          description: 'Password for user "admin".'
          defaultValue: $$cap_gen_random_hex(12)

    instructions:
        start: IP address and datacenter infrastructure management.

            ---

            Find out more at https://netbox.dev. This app's container image was built using https://docs.linuxserver.io/images/docker-netbox.

        end: >-
            Netbox is deployed, it might take few moments before it's fully started.

            Login with user `admin` and password `$$cap_superuser_pass`.


            Volumes created for `config`, `scripts`, and `reports` are available in your default folder for Caprover volumes, typically `/var/lib/docker/volumes`

    displayName: Netbox
    isOfficial: false
    description: IP address management (IPAM) and data center infrastructure management (DCIM) tool
    documentation: 'Read more at: https://docs.linuxserver.io/images/docker-netbox'
