WIP: Image refactor

- docker_container cannot take upload as a parameter, leaving
  no choice but to use docker_container like a savage.
- This will take some backward refactors.
This commit is contained in:
Nemo 2018-10-13 20:55:20 +05:30
parent 809755e10d
commit c57b4b2c72
7 changed files with 54 additions and 46 deletions

View File

@ -13,10 +13,9 @@ module "lychee" {
}, },
] ]
uploads = [{ files = "/config/lychee/user.ini"
content = "${file("${path.module}/docker/conf/lychee.php.ini")}"
file = "/config/lychee/user.ini" contents = ["${file("${path.module}/docker/conf/lychee.php.ini")}"]
}]
web { web {
expose = true expose = true

View File

@ -22,15 +22,14 @@ module "airsonic" {
"JAVA_OPTS=-Xmx512m -Dserver.use-forward-headers=true -Dserver.context-path=/", "JAVA_OPTS=-Xmx512m -Dserver.use-forward-headers=true -Dserver.context-path=/",
] ]
uploads = [ files = [
{ "/usr/lib/jvm/java-1.8-openjdk/jre/lib/airsonic.properties",
file = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/airsonic.properties" "/usr/lib/jvm/java-1.8-openjdk/jre/lib/sound.properties",
content = "${data.template_file.airsonic-properties-file.rendered}" ]
},
{ contents = [
file = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/sound.properties" "${data.template_file.airsonic-properties-file.rendered}",
content = "${file("${path.module}/conf/airsonic.sound.properties")}" "${file("${path.module}/conf/airsonic.sound.properties")}",
},
] ]
volumes = [ volumes = [

View File

@ -23,17 +23,11 @@ resource "docker_container" "container" {
// Only attach the traefik network if // Only attach the traefik network if
// service is exposed to the web // service is exposed to the web
networks = ["${concat(var.networks, split(",", networks = ["${concat(var.networks,split(",",lookup(var.web, "expose", "false") == "false" ? "" :"${data.docker_network.traefik.id}"))}"]
lookup(var.web, "expose", "false") == "false" ?
"" :
"${data.docker_network.traefik.id}"
))}"]
memory = "${local.resource["memory"]}" memory = "${local.resource["memory"]}"
volumes = "${var.volumes}" volumes = ["${var.volumes}"]
upload = "${var.uploads}"
# Look at this monstrosity # Look at this monstrosity
# And then https://github.com/hashicorp/terraform/issues/12453#issuecomment-365569618 # And then https://github.com/hashicorp/terraform/issues/12453#issuecomment-365569618

View File

@ -88,8 +88,3 @@ variable "volumes" {
type = "list" type = "list"
default = [] default = []
} }
variable "uploads" {
description = "uploads"
default = []
}

16
modules/image/main.tf Normal file
View File

@ -0,0 +1,16 @@
variable "image" {
description = "image to use"
}
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}"]
}
output "image" {
value = "${docker_image.image.latest}"
}

View File

@ -1,7 +1,12 @@
module "image" {
source = "../modules/image"
image = "tomsquest/docker-radicale:latest"
}
module "container" { module "container" {
name = "radicale" name = "radicale"
source = "../modules/container" source = "../modules/container"
image = "tomsquest/docker-radicale:latest" image = "${module.image.image}"
web { web {
expose = true expose = true
@ -20,18 +25,18 @@ module "container" {
}, },
] ]
uploads = [ # uploads = [
{ # {
content = "${file("${path.module}/config")}" # content = "${file("${path.module}/config")}"
file = "/config/config" # file = "/config/config"
}, # },
{ # {
content = "${file("${path.module}/logging.conf")}" # content = "${file("${path.module}/logging.conf")}"
file = "/config/logging" # file = "/config/logging"
}, # },
{ # {
content = "${file("${path.module}/users")}" # content = "${file("${path.module}/users")}"
file = "/config/users" # file = "/config/users"
}, # },
] # ]
} }

View File

@ -9,9 +9,10 @@ module "rss-bridge" {
} }
networks = "${list(module.docker.traefik-network-id)}" networks = "${list(module.docker.traefik-network-id)}"
files = ["/app/public/whitelist.txt"]
uploads = [{ contents = [
content = <<EOF <<EOF
AmazonBridge AmazonBridge
BandcampBridge BandcampBridge
ContainerLinuxReleasesBridge ContainerLinuxReleasesBridge
@ -29,7 +30,6 @@ SteamBridge
StripeAPIChangeLogBridge StripeAPIChangeLogBridge
AmazonPriceTrackerBridge AmazonPriceTrackerBridge
EOF EOF
,
file = "/app/public/whitelist.txt" ]
}]
} }