From 96a376a917d6a356cdb77a771ecbc80fde76e846 Mon Sep 17 00:00:00 2001 From: Layla Manley Date: Mon, 3 Jun 2024 19:07:46 +0200 Subject: [PATCH] Add uptime-kuma to Terraform --- services/uptime-kuma/Taskfile.dist.yml | 8 +++++++ services/uptime-kuma/_common/main.tf | 29 ++++++++++++++++++++++++ services/uptime-kuma/_common/vars.tf | 10 ++++++++ services/uptime-kuma/_common/versions.tf | 7 ++++++ services/uptime-kuma/main/main.tf | 6 +++++ services/uptime-kuma/main/versions.tf | 7 ++++++ 6 files changed, 67 insertions(+) create mode 100644 services/uptime-kuma/Taskfile.dist.yml create mode 100644 services/uptime-kuma/_common/main.tf create mode 100644 services/uptime-kuma/_common/vars.tf create mode 100644 services/uptime-kuma/_common/versions.tf create mode 100644 services/uptime-kuma/main/main.tf create mode 100644 services/uptime-kuma/main/versions.tf diff --git a/services/uptime-kuma/Taskfile.dist.yml b/services/uptime-kuma/Taskfile.dist.yml new file mode 100644 index 0000000..a4027a7 --- /dev/null +++ b/services/uptime-kuma/Taskfile.dist.yml @@ -0,0 +1,8 @@ +version: "3" + +includes: + tf: + vars: + SERVICE: "uptime-kuma" + ENVIRONMENT: "main" + taskfile: ../../taskfiles/Taskfile_service.dist.yml diff --git a/services/uptime-kuma/_common/main.tf b/services/uptime-kuma/_common/main.tf new file mode 100644 index 0000000..f91cf60 --- /dev/null +++ b/services/uptime-kuma/_common/main.tf @@ -0,0 +1,29 @@ +resource "docker_container" "uptime_kuma" { + image = "louislam/uptime-kuma:${var.uptime_kuma_version}" + name = var.container_name + + restart = "always" + + env = [] + + ports { + internal = 3001 + external = 3005 + } + + # Allows uptime-kuma to access the Docker socket + mounts { + target = "/var/run/docker.sock" + source = "/var/run/docker.sock" + read_only = false + type = "bind" + } + + mounts { + target = "/app/data" + source = "/volume1/cloud/${var.container_name}/data" + read_only = false + type = "bind" + } + +} diff --git a/services/uptime-kuma/_common/vars.tf b/services/uptime-kuma/_common/vars.tf new file mode 100644 index 0000000..8a30e7e --- /dev/null +++ b/services/uptime-kuma/_common/vars.tf @@ -0,0 +1,10 @@ +variable "uptime_kuma_version" { + description = "Container tag" + type = string + default = "1" +} + +variable "container_name" { + description = "Container name" + type = string +} diff --git a/services/uptime-kuma/_common/versions.tf b/services/uptime-kuma/_common/versions.tf new file mode 100644 index 0000000..b433ffb --- /dev/null +++ b/services/uptime-kuma/_common/versions.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + } + } +} diff --git a/services/uptime-kuma/main/main.tf b/services/uptime-kuma/main/main.tf new file mode 100644 index 0000000..717c5ed --- /dev/null +++ b/services/uptime-kuma/main/main.tf @@ -0,0 +1,6 @@ +module "uptime-kuma" { + source = "../_common" + + container_name = "uptime-kuma" + uptime_kuma_version = "1" +} diff --git a/services/uptime-kuma/main/versions.tf b/services/uptime-kuma/main/versions.tf new file mode 100644 index 0000000..b433ffb --- /dev/null +++ b/services/uptime-kuma/main/versions.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + } + } +}