job "minio-singleton" {
  datacenters = ["dc1"]
  type        = "service"

  group "minio" {
    count = 1

    network {
      mode = "bridge"
      port "console" {
        to = 9090
      }
    }

    service {
      # Make available to other services by the 'minio-singleton' name
      name = "minio-singleton"
      port = "9000"
      tags = ["traefik.enable=false"] # Hide minio from traefik

      connect {
        sidecar_service {
          tags = ["traefik.enable=false"] # Hide minio from traefik
        }
      }
    }

    volume "minio-data" {
      type      = "host"
      source    = "minio"
    }

    task "minio" {
      driver = "docker"

      volume_mount {
        volume      = "minio-data"
        destination = "/data"
      }

      config {
        image = "quay.io/minio/minio"
        ports = ["console"]
        command = "server"
        args = ["/data", "--console-address", ":9090"]
      }

      resources {
        cpu    = 100
        memory = 2000
      }

      env {
        MINIO_ROOT_USER="op://InfraSecrets/Minio-Singleton/username"
        MINIO_ROOT_PASSWORD="op://InfraSecrets/Minio-Singleton/password"
      }
    }
  }
}