Comment on Migrated my Docker Compose homelab to OpenTofu

cichy1173@szmer.info ⁨2⁩ ⁨days⁩ ago

Finally found someone who uses OpenTofu for Docker too. I saw many opinions and thinking that dropping Compose for OpenTofu/Terraform is silly, because Compose is “more native”. I use OpenTofu for Docker too, but I structured code in other way, I have a module that mimics compose in some way, but is simpler for me to use. I published module here: codeberg.org/cichy1173/cichyform

I do not published my IaC, but I can show how code looks like for service:

module "adguard" {
  source = "git::ssh://git@codeberg.org/cichy1173/mylab-opentofu.git//modules/docker_service?ref=docker_service-v1.1"
  service_name = "adguardhome"
  image_name   = "adguard/adguardhome:latest"

  volumes = [
    {
      host_path      = "/home/cichy/docker/adguard/adguard/conf"
      container_path = "/opt/adguardhome/conf"
    },
    {
      host_path      = "/home/cichy/docker/adguard/adguard/work"
      container_path = "/opt/adguardhome/work"
    }
  ]
  
  ports = [
    {
      internal = 53
      external = 53
      protocol = "udp"
    },
    {
      internal = 80
      external = 80
    },
    {
      internal = 443
      external = 443
    },
    {
      internal = 853
      external = 853
    },
    {
      internal = 3000
      external = 3000
    }
  ]

  environment_variables = []
}

I also created an Forgejo Action to run plan on stacks with this module to check if there is a new image under the tag :latest. Oh, and also I manage Adguard Home using OpenTofu, it is very powerful: codeberg.org/…/adguard-home-cm-repository

source
Sort:hotnewtop