job "vikunja" {
  datacenters = ["alo"]

  meta {
    uuid = uuidv4()
  }

  group "web" {
    network {
      port "http" {
        to = 3456
      }
    }

    task "server" {
      driver = "docker"

      config {
        image = "vikunja/vikunja:latest"
        ports = ["http"]
        volumes = [
          "/data/services/vikunja/config.yml:/app/vikunja/config.yml:ro",
          "/data/services/vikunja/db:/db",
          "/data/services/vikunja/files:/app/vikunja/files",
        ]
      }

      resources {
        memory = 1024
      }

      service {
        name = "vikunja"
        port = "http"

        tags = [
          "traefik.enable=true",
          "traefik.http.routers.vikunja.entryPoints=websecure",
          "traefik.http.routers.vikunja.rule=Host(`todo.alo.land`)",
        ]
      }
    }
  }

  group "search" {
    network {
      port "http" {
        static = 8108
      }
    }

    task "typesense" {
      driver = "docker"

      config {
        image = "typesense/typesense:27.1"
        ports = ["http"]
        volumes = [
          "/data/services/vikunja/typesense:/data",
        ]
      }

      env {
        TYPESENSE_DATA_DIR = "/data"
        # FIXME: this should probably be more restricted
        TYPESENSE_API_KEY = "NRVgtCc6cmYuPbq4flmS"
        TYPESENSE_ENABLE_CORS = "true"
      }

      resources {
        memory = 1024
      }

      service {
        name = "typesense"
        port = "http"
      }
    }
  }
}
