From 2fb18878ca7feb5e2860b4a68c0f7e391bdfc14b Mon Sep 17 00:00:00 2001
From: Nemo <me@captnemo.in>
Date: Sat, 15 Sep 2018 17:43:44 +0530
Subject: [PATCH] lychee moved to container module

---
 lychee.tf         | 30 ++++++++++++++++++++++++++++++
 docker/data.tf    |  4 ----
 docker/images.tf  |  5 -----
 docker/lychee.tf  | 37 -------------------------------------
 docker/outputs.tf |  4 ----
 5 files changed, 30 insertions(+), 50 deletions(-)

diff --git a/lychee.tf b/lychee.tf
new file mode 100644
index 0000000..46d6fe6 100644
--- /dev/null
+++ a/lychee.tf
@@ -1,0 +1,30 @@
+module "lychee" {
+  source = "modules/container"
+  name   = "lychee"
+  image  = "linuxserver/lychee:latest"
+
+  volumes = [{
+    host_path      = "/mnt/xwing/config/lychee"
+    container_path = "/config"
+  },
+    {
+      host_path      = "/mnt/xwing/data/lychee"
+      container_path = "/pictures"
+    },
+  ]
+
+  uploads = [{
+    content = "${file("${path.module}/docker/conf/lychee.php.ini")}"
+    file    = "/config/lychee/user.ini"
+  }]
+
+  web {
+    expose = true
+    host   = "pics.bb8.fun"
+  }
+
+  env = [
+    "PUID=986",
+    "PGID=984",
+  ]
+}
diff --git a/docker/data.tf b/docker/data.tf
index eb7a06d..f32c089 100644
--- a/docker/data.tf
+++ a/docker/data.tf
@@ -11,7 +11,3 @@
 data "docker_registry_image" "ubooquity" {
   name = "linuxserver/ubooquity:latest"
 }
-
-data "docker_registry_image" "lychee" {
-  name = "linuxserver/lychee:latest"
-}
diff --git a/docker/images.tf b/docker/images.tf
index 22d72cd..7ba3ba5 100644
--- a/docker/images.tf
+++ a/docker/images.tf
@@ -12,8 +12,3 @@
   name          = "${data.docker_registry_image.ubooquity.name}"
   pull_triggers = ["${data.docker_registry_image.ubooquity.sha256_digest}"]
 }
-
-resource "docker_image" "lychee" {
-  name          = "${data.docker_registry_image.lychee.name}"
-  pull_triggers = ["${data.docker_registry_image.lychee.sha256_digest}"]
-}
diff --git a/docker/lychee.tf b/docker/lychee.tf
deleted file mode 100644
index 079dcc5..0000000 100644
--- a/docker/lychee.tf
+++ /dev/null
@@ -1,37 +1,0 @@
-resource "docker_container" "lychee" {
-  name  = "lychee"
-  image = "${docker_image.lychee.latest}"
-
-  restart               = "unless-stopped"
-  destroy_grace_seconds = 10
-  must_run              = true
-
-  volumes {
-    host_path      = "/mnt/xwing/config/lychee"
-    container_path = "/config"
-  }
-
-  volumes {
-    host_path      = "/mnt/xwing/data/lychee"
-    container_path = "/pictures"
-  }
-
-  upload {
-    content = "${file("${path.module}/conf/lychee.php.ini")}"
-    file    = "/config/lychee/user.ini"
-  }
-
-  labels = "${merge(
-    local.traefik_common_labels,
-    map(
-      "traefik.port", 80,
-      "traefik.frontend.rule", "Host:pics.${var.domain}",
-  ))}"
-
-  env = [
-    "PUID=986",
-    "PGID=984",
-  ]
-
-  # links = ["${var.links-mariadb}"]
-}
diff --git a/docker/outputs.tf b/docker/outputs.tf
index d0fa477..a41efd4 100644
--- a/docker/outputs.tf
+++ a/docker/outputs.tf
@@ -1,7 +1,3 @@
-output "lychee-ip" {
-  value = "${docker_container.lychee.ip_address}"
-}
-
 output "names-traefik" {
   value = "${docker_container.traefik.name}"
 }
--
rgit 0.1.5