captainVersion: 4
services:
    $$cap_appname-db:
        image: postgres:$$db_version
        restart: always
        volumes:
            - $$cap_appname-data:/var/lib/postgresql/data
        environment:
            POSTGRES_DB: invidious
            POSTGRES_PASSWORD: kemal
            POSTGRES_USER: kemal
        healthcheck:
            test: ['CMD', 'pg_isready', '-U', 'postgres']
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        image: omarroth/invidious$$cap_version
        restart: always
        environment:
            # Adapted from ./config/config.yml
            INVIDIOUS_CONFIG: |
                channel_threads: 1
                check_tables: true
                feed_threads: 1
                db:
                  user: kemal
                  password: kemal
                  host: srv-captain--$$cap_appname-db
                  port: 5432
                  dbname: invidious
                full_refresh: false
                https_only: false
                domain:
        caproverExtra:
            containerHttpPort: '3000'

caproverOneClickApp:
    variables:
        - id: '$$cap_version'
          label: Invidious Version
          defaultValue: '@sha256:31d0c0061778fecc98b693c8d53073e5ac758b1d570ac2881370547079fa2a4c'
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/omarroth/invidious/tags. If you want to use the latest tag (or a versioned release, if available), start with a colon (e.g. :latest).
          validRegex: "/^([^\\s^\\/])+$/"
        - id: '$$db_version'
          label: Postgres Version
          defaultValue: '10' # there is no other tag provided
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/postgres?tab=tags
          validRegex: "/^([^\\s^\\/])+$/"
    instructions:
        start: |-
            Invidious is an alternative front-end to YouTube. 
            More details: https://github.com/iv-org/invidious
        end: |-
            Invidious has been successfully deployed! It may take a couple of minutes until the web frontend can be reached.
    displayName: Invidious
    isOfficial: true
    description: Invidious is an alternative front-end to YouTube.
    documentation: See https://github.com/iv-org/invidious
