job "gitea" {
  region      = "global"
  datacenters = ["samfelag"]
  type        = "service"

  group "gitea" {
    count = 1

    restart {
      attempts = 5
      delay    = "1m"
    }

    network {
      port "http" {
        to     = 3000
      }
      port "ssh" {
        static       = 2222
        to           = 22
	    host_network = "public"
      }
    }

    task "gitea" {
      driver = "docker"

      env {
        USER_UID   = "1001"
        USER_GID   = "1001"
      }

      config {
        image = "gitea/gitea:latest"
        ports = ["http", "ssh"]
	    volumes = ["/mnt/vatnajokull/nomad_volumes/gitea/data:/data"]
      }

      resources {
        cpu    = 1000
        memory = 256
      }

      service {
        name = "gitea"
        port = "http"
       
        check {
          type     = "tcp"
          port     = "http"
          interval = "30s"
          timeout  = "2s"
        }
      }

      service {
        name = "gitea-ssh"
        port = "ssh"

        check {
          type     = "tcp"
          port     = "ssh"
          interval = "30s"
          timeout  = "2s"
        }
      }

    }
  }
}

