# Starting point for the tofu-drift task. OpenTofu manages a network and an app container through Docker. The app
# writes to /data, but /data lives inside the container, so replacing the container loses it. Fix that, so a
# re-apply after drift brings the container back without losing or recreating the data.
terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "~> 3.0"
    }
  }
}

provider "docker" {}

resource "docker_network" "app" {
  name = "skilltree-iac"
}

resource "docker_image" "alpine" {
  name         = "alpine:3.20"
  keep_locally = true
}

resource "docker_container" "app" {
  name    = "skilltree-iac-app"
  image   = docker_image.alpine.image_id
  command = ["sleep", "infinity"]

  networks_advanced {
    name = docker_network.app.name
  }

  labels {
    label = "skilltree.task"
    value = "tofu-drift"
  }
}
