data "docker_registry_image" "mitmproxy" {
  name = "ghcr.io/benzine-framework/mitmproxy:10.1.1"
}
resource "docker_service" "mitmproxy" {
  name = "mitmproxy"
  task_spec {
    container_spec {
      image = "${data.docker_registry_image.mitmproxy.name}@${data.docker_registry_image.mitmproxy.sha256_digest}"
      command = [
        "mitmweb",
        "--web-host", "0.0.0.0",
        "--web-port", "8081",
        #"--listen-host", "0.0.0.0",
        #"--listen-port", "8080",
        "--ssl-insecure",
      ]
      #healthcheck {
      #  test         = ["CMD-SHELL", " curl -I -x http://localhost:8080 -k http://172.17.0.1 || exit 1"]
      #  start_period = "10s"
      #  interval     = "10s"
      #  timeout      = "5s"
      #  retries      = 5
      #}
    }
    restart_policy {
      condition = "any"
      delay     = "0s"
      window    = "0s"
    }
  }
  endpoint_spec {
    ports {
      target_port    = 8081
      published_port = 8081
      publish_mode   = "ingress"
    }
    ports {
        target_port    = 8080
        published_port = 8080
        publish_mode   = "ingress"
    }
  }
}