# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Lavalink
spec:
    description: A standalone audio sending node based on Lavaplayer and Koe.
    icon: https://github.com/lavalink-devs/Lavalink/raw/master/branding/lavalink.svg
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: The domain name of your Lavalink website.
    tags:
        - ChatGPT
        - Website
    readme: "A standalone audio sending node based on Lavaplayer and Koe. Allows for sending audio without it ever reaching any of your shards.\n\nBeing used in production by FredBoat, Dyno, LewdBot, and more. \n"
    services:
        - name: lavalink
          icon: https://github.com/lavalink-devs/Lavalink/raw/master/branding/lavalink.svg
          template: PREBUILT
          spec:
            id: lavalink
            source:
                image: ghcr.io/lavalink-devs/lavalink:4.1.2-alpine
            ports:
                - id: web
                  port: 2333
                  type: HTTP
            env:
                JAVA_OPTS:
                    default: -Xmx2G
                LAVA_SERVER_PASSWORD:
                    default: ${PASSWORD}
                SERVER_PORT:
                    default: "2333"
            configs:
                - path: /opt/Lavalink/application.yml
                  template: |
                    plugins:
                      lavasrc:
                        providers: # Custom providers for track loading. This is the default
                          - 'ytsearch:"%ISRC%"' # If ISRC available, search on youtube
                          - "ytmsearch:%QUERY%" # If you want music.youtube results first
                          - "ytsearch:%QUERY%" # If no result found on music.youtube, search on www.youtube
                          - "scsearch:%QUERY%" # Last try to search on soundcloud.
                        sources:
                          spotify: true # Enable Spotify source
                          applemusic: false # Enable Apple Music source
                          deezer: false # Enable Deezer source
                          yandexmusic: false # Enable Yandex Music source
                          flowerytts: false # Enable Flowery TTs source
                          youtube: true # Enable YouTube search source (https://github.com/topi314/LavaSearch)
                        spotify:
                          clientId: "c9071d83b23e420e96eaf4294b928477"
                          clientSecret: "15a74ec5e31d4dd5a7ffb1a0dbe97f90"
                          countryCode: "US" # the country code you want to use for filtering the artists top tracks. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
                          playlistLoadLimit: 6 # The number of pages at 100 tracks each
                          albumLoadLimit: 6 # The number of pages at 50 tracks each
                    server: # REST and WS server
                      port: 2333
                      address: 0.0.0.0
                    lavalink:
                      plugins:
                        - dependency: "com.github.topi314.lavasearch:lavasearch-plugin:1.0.0"
                          repository: "https://maven.topi.wtf/releases"
                        - dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.0.0"
                          repository: "https://maven.topi.wtf/releases"
                        - dependency: "dev.lavalink.youtube:youtube-plugin:1.3.0"
                          snapshot: false
                      server:
                        password: ${LAVA_SERVER_PASSWORD}
                        sources:
                          youtube: true
                          bandcamp: true
                          soundcloud: true
                          twitch: true
                          vimeo: true
                          mixer: true
                          http: true
                          local: false
                        bufferDurationMs: 400 # The duration of the NAS buffer. Higher values fare better against longer GC pauses. Minimum of 40ms, lower values may introduce pauses.
                        frameBufferDurationMs: 5000 # How many milliseconds of audio to keep buffered
                        opusEncodingQuality: 0 # Opus encoder quality. Valid values range from 0 to 10, where 10 is the best quality but is the most expensive on the CPU.
                        resamplingQuality: LOW # Quality of resampling operations. Valid values are LOW, MEDIUM and HIGH, where HIGH uses the most CPU.
                        trackStuckThresholdMs: 10000 # The threshold for how long a track can be stuck. A track is stuck if it does not return any audio data.
                        useSeekGhosting: true # Seek ghosting is the effect where whilst a seek is in progress, the audio buffer is read from until empty, or until seek is ready.
                        youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
                        playerUpdateInterval: 5 # How frequently to send player updates to clients, in seconds
                        youtubeSearchEnabled: true
                        soundcloudSearchEnabled: true
                        gc-warnings: true
                        #ratelimit:
                        #ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks
                        #excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
                        #strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
                        #searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
                        #retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times

                    metrics:
                      prometheus:
                        enabled: false
                        endpoint: /metrics

                    sentry:
                      dsn: ""
                      environment: ""
                    #  tags:
                    #    some_key: some_value
                    #    another_key: another_value

                    logging:
                      file:
                        max-history: 30
                        max-size: 1GB
                      path: ./logs/

                      level:
                        root: INFO
                        lavalink: INFO

                      request:
                        enabled: true
                        includeClientInfo: true
                        includeHeaders: false
                        includeQueryString: true
                        includePayload: true
                        maxPayloadLength: 10000
                  permission: null
                  envsubst: true
          domainKey: PUBLIC_DOMAIN
