Creates a generic docker-container module
This commit is contained in:
parent
1f545f3117
commit
3322870a53
7
main.tf
7
main.tf
|
@ -90,13 +90,6 @@ module "monicahq" {
|
||||||
postgres-network-id = "${module.db.postgres-network-id}"
|
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" {
|
module "resilio" {
|
||||||
source = "resilio"
|
source = "resilio"
|
||||||
domain = "sync.bb8.fun"
|
domain = "sync.bb8.fun"
|
||||||
|
|
|
@ -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}"
|
||||||
|
}
|
|
@ -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 = {}
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -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
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
variable "domain" {
|
|
||||||
type = "string"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "traefik-labels" {
|
|
||||||
type = "map"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "traefik-network-id" {}
|
|
|
@ -77,3 +77,8 @@ variable "monica-db-password" {}
|
||||||
variable "monica-app-key" {}
|
variable "monica-app-key" {}
|
||||||
variable "monica-hash-salt" {}
|
variable "monica-hash-salt" {}
|
||||||
variable "monica-smtp-password" {}
|
variable "monica-smtp-password" {}
|
||||||
|
|
||||||
|
variable "root-domain" {
|
||||||
|
description = "root domain for most applications"
|
||||||
|
default = "bb8.fun"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue