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 = [{
content = "${file("${path.module}/docker/conf/lychee.php.ini")}"
file = "/config/lychee/user.ini"
}]
files = "/config/lychee/user.ini"
contents = ["${file("${path.module}/docker/conf/lychee.php.ini")}"]
web {
expose = true

View File

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

View File

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

View File

@ -88,8 +88,3 @@ variable "volumes" {
type = "list"
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" {
name = "radicale"
source = "../modules/container"
image = "tomsquest/docker-radicale:latest"
image = "${module.image.image}"
web {
expose = true
@ -20,18 +25,18 @@ module "container" {
},
]
uploads = [
{
content = "${file("${path.module}/config")}"
file = "/config/config"
},
{
content = "${file("${path.module}/logging.conf")}"
file = "/config/logging"
},
{
content = "${file("${path.module}/users")}"
file = "/config/users"
},
]
# uploads = [
# {
# content = "${file("${path.module}/config")}"
# file = "/config/config"
# },
# {
# content = "${file("${path.module}/logging.conf")}"
# file = "/config/logging"
# },
# {
# content = "${file("${path.module}/users")}"
# file = "/config/users"
# },
# ]
}

View File

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