diff --git a/main.tf b/main.tf index 90403e0..ff9e4fa 100644 --- a/main.tf +++ b/main.tf @@ -90,13 +90,6 @@ module "monicahq" { postgres-network-id = "${module.db.postgres-network-id}" } -module "requestbin" { - source = "requestbin" - domain = "requestbin.bb8.fun" - traefik-labels = "${var.traefik-common-labels}" - traefik-network-id = "${module.docker.traefik-network-id}" -} - module "resilio" { source = "resilio" domain = "sync.bb8.fun" diff --git a/modules/container/main.tf b/modules/container/main.tf new file mode 100644 index 0000000..b539842 --- /dev/null +++ b/modules/container/main.tf @@ -0,0 +1,23 @@ +data "docker_registry_image" "image" { + name = "${var.image}" +} + +resource "docker_image" "image" { + name = "${data.docker_registry_image.image.name}" + pull_triggers = ["${data.docker_registry_image.image.sha256_digest}"] +} + +resource "docker_container" "container" { + name = "${var.name}" + image = "${docker_image.image.latest}" + ports = "${var.ports}" + restart = "${var.restart}" + env = "${var.env}" + command = "${var.command}" + entrypoint = "${var.entrypoint}" + user = "${var.user}" + networks = ["${var.networks}"] + labels = "${var.labels}" + destroy_grace_seconds = "${var.destroy_grace_seconds}" + must_run = "${var.must_run}" +} diff --git a/modules/container/vars.tf b/modules/container/vars.tf new file mode 100644 index 0000000..edd44c4 --- /dev/null +++ b/modules/container/vars.tf @@ -0,0 +1,61 @@ +variable "image" { + description = "docker image (with tag)" +} + +variable "name" { + description = "docker container name" +} + +variable "ports" { + description = "list of port mappings" + type = "list" + default = [] +} + +variable "networks" { + description = "list of networks" + type = "list" + default = [] +} + +variable "restart" { + description = "restart-policy" + default = "unless-stopped" +} + +variable "must_run" { + description = "If true, then the Docker container will be kept running. " + default = "true" + type = "string" +} + +variable "user" { + description = "user" + default = "" +} + +variable "destroy_grace_seconds" { + description = "Container will be destroyed after n seconds or on successful stop." + default = 10 + type = "string" +} + +variable "command" { + description = "command" + default = [] +} + +variable "entrypoint" { + description = "entrypoint" + default = [] +} + +variable "env" { + description = "environment variables" + default = [] +} + +variable "labels" { + description = "labels" + default = {} +} diff --git a/requestbin.tf b/requestbin.tf new file mode 100644 index 0000000..948a6ae --- /dev/null +++ b/requestbin.tf @@ -0,0 +1,16 @@ +module "requestbin" { + name = "requestbin" + source = "./modules/container" + image = "jankysolutions/requestbin:latest" + + labels = "${merge( + var.traefik-common-labels, map( + "traefik.port", 8000, + "traefik.frontend.rule","Host:requestbin.${var.root-domain}" + ))}" + + networks = "${list(module.docker.traefik-network-id)}" + + destroy_grace_seconds = 10 + must_run = true +} diff --git a/requestbin/README.md b/requestbin/README.md deleted file mode 100644 index 16e96a1..0000000 --- a/requestbin/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# requestbin - -- runscope has stopped hosting their public version of Requestb.in -- https://github.com/Runscope/requestbin#readme - -There is no official image: https://github.com/Runscope/requestbin/issues/51 so using an unofficial image at https://hub.docker.com/r/jankysolutions/requestbin diff --git a/requestbin/main.tf b/requestbin/main.tf deleted file mode 100644 index ce8d936..0000000 --- a/requestbin/main.tf +++ /dev/null @@ -1,25 +0,0 @@ -data "docker_registry_image" "requestbin" { - name = "jankysolutions/requestbin:latest" -} - -resource "docker_image" "requestbin" { - name = "${data.docker_registry_image.requestbin.name}" - pull_triggers = ["${data.docker_registry_image.requestbin.sha256_digest}"] -} - -resource "docker_container" "requestbin" { - name = "requestbin" - image = "${docker_image.requestbin.latest}" - - labels = "${merge( - var.traefik-labels, map( - "traefik.port", 8000, - "traefik.frontend.rule","Host:${var.domain}" - ))}" - - networks = ["${var.traefik-network-id}"] - - restart = "unless-stopped" - destroy_grace_seconds = 10 - must_run = true -} diff --git a/requestbin/variables.tf b/requestbin/variables.tf deleted file mode 100644 index 500e0e6..0000000 --- a/requestbin/variables.tf +++ /dev/null @@ -1,9 +0,0 @@ -variable "domain" { - type = "string" -} - -variable "traefik-labels" { - type = "map" -} - -variable "traefik-network-id" {} diff --git a/variables.tf b/variables.tf index 835387d..93fde51 100644 --- a/variables.tf +++ b/variables.tf @@ -77,3 +77,8 @@ variable "monica-db-password" {} variable "monica-app-key" {} variable "monica-hash-salt" {} variable "monica-smtp-password" {} + +variable "root-domain" { + description = "root domain for most applications" + default = "bb8.fun" +}