terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "3.6.2"
    }
  }
}

provider "docker" {
  host = "unix:///run/podman/podman.sock"
}

resource "docker_image" "syslog_ng" {
  name         = "lscr.io/linuxserver/syslog-ng:latest"
  keep_locally = false
}

resource "docker_container" "syslog_ng" {
  name  = "syslog-ng"
  image = docker_image.syslog_ng.image_id

  restart = "unless-stopped"

  ports {
    internal = 5514
    external = 514
    protocol = "udp"
  }

  ports {
    internal = 6601
    external = 601
    protocol = "tcp"
  }

  ports {
    internal = 6514
    external = 6514
    protocol = "tcp"
  }

  volumes {
    host_path      = "/srv/syslog/config"
    container_path = "/config"
  }

  volumes {
    host_path      = "/srv/syslog/log"
    container_path = "/var/log"
  }
}
