variable "version" {
  type = string
}

job "adriano.fyi" {
  datacenters = ["dc1"]
  namespace = "default"

  group "task" {
    network {
      port "http" {
        to = 3000
        host_network = "private"
      }
    }

    task "webserver" {
      driver = "docker"

      artifact {
        source = "s3://us-east-1.linodeobjects.com/adriano-fyi-static-site/adriano_fyi-${GITHUB_SHA}.tar"
        options {
          aws_access_key_id     = "LPG6GTPT3UY81QJ7Q6H2"
          aws_access_key_secret = "C0K4XfDNDDQQM7xcph5hy33QCYtZflpiEVAIeKJP"
          # Leave the archive in tar format
          archive = false
        }
      }

      config {
        load = "adriano_fyi-${var.version}.tar"
        image = "adriano_fyi:${var.version}"
        ports = ["outside_careers"]
      }

      resources {
        cpu = 1024
        memory = 1024
      }

      service {
        port = "outside_careers"
        name = "outsidecareers"
        provider = "nomad"
      }
    }
  }
}
