variable "wait_on" {
  type        = any
  description = "Resources to wait on"
  default     = true
}

variable "server_ip" {
  type = string
}

variable "ssh_private_key_path" {
  type = string
}

variable "server_domain" {
  type = string
}

module "navidrome" {
  source = "../quadlet-app"
  wait_on = var.wait_on

  server_ip            = var.server_ip
  ssh_private_key_path = var.ssh_private_key_path

  app_name = "navidrome"
  image    = "docker.io/deluan/navidrome:latest"
  ports    = ["4533:4533"]
  volumes = [
    "/opt/storage/data/navidrome:/data:Z",
    "/opt/storage/media/music:/music:ro,Z",
  ]

  environment = {
    ND_LOGLEVEL="info"
    ND_ENABLEINSIGHTSCOLLECTOR="false"
  }

  haproxy_services = [
    {
      name   = "navidrome"
      domain = "navidrome.${var.server_domain}"
      port   = "4533"
      host   = "127.0.0.1"
      tls    = false
    },
  ]

}

output "app_urls" {
  value = module.navidrome.app_urls
}

output "installed" {
  value = true
  depends_on = [module.navidrome.installed]
}
