Attempt at modularizing airsonic
This commit is contained in:
parent
2fb18878ca
commit
167e58f8de
|
@ -1,61 +1,56 @@
|
||||||
resource "docker_container" "airsonic" {
|
module "airsonic" {
|
||||||
name = "airsonic"
|
source = "../modules/container"
|
||||||
image = "${docker_image.airsonic.latest}"
|
image = "linuxserver/airsonic:latest"
|
||||||
restart = "unless-stopped"
|
name = "airsonic"
|
||||||
destroy_grace_seconds = 30
|
|
||||||
must_run = true
|
|
||||||
|
|
||||||
# Unfortunately, the --device flag is not yet supported
|
resource {
|
||||||
# in docker/terraform:
|
memory = "256"
|
||||||
# https://github.com/terraform-providers/terraform-provider-docker/issues/30
|
}
|
||||||
|
|
||||||
upload {
|
web {
|
||||||
content = "${data.template_file.airsonic-properties-file.rendered}"
|
port = 4040
|
||||||
file = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/airsonic.properties"
|
host = "airsonic.bb8.fun"
|
||||||
|
expose = true
|
||||||
}
|
}
|
||||||
# This lets the Jukebox use ALSA
|
|
||||||
upload {
|
user = "lounge:audio"
|
||||||
content = "${file("${path.module}/conf/airsonic.sound.properties")}"
|
|
||||||
file = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/sound.properties"
|
|
||||||
}
|
|
||||||
volumes {
|
|
||||||
host_path = "/mnt/xwing/config/airsonic2"
|
|
||||||
container_path = "/config"
|
|
||||||
}
|
|
||||||
volumes {
|
|
||||||
host_path = "/mnt/xwing/media/Music"
|
|
||||||
container_path = "/music"
|
|
||||||
}
|
|
||||||
volumes {
|
|
||||||
host_path = "/mnt/xwing/config/airsonic/playlists"
|
|
||||||
container_path = "/playlists"
|
|
||||||
}
|
|
||||||
volumes {
|
|
||||||
host_path = "/mnt/xwing/config/airsonic/podcasts"
|
|
||||||
container_path = "/podcasts"
|
|
||||||
}
|
|
||||||
labels {
|
|
||||||
"traefik.enable" = "true"
|
|
||||||
"traefik.port" = "4040"
|
|
||||||
"traefik.frontend.rule" = "Host:airsonic.in.${var.domain},airsonic.${var.domain}"
|
|
||||||
"traefik.frontend.passHostHeader" = "true"
|
|
||||||
}
|
|
||||||
# lounge:tatooine
|
|
||||||
env = [
|
env = [
|
||||||
"PUID=1004",
|
"PUID=1004",
|
||||||
"PGID=1003",
|
"PGID=1003",
|
||||||
"TZ=Asia/Kolkata",
|
"TZ=Asia/Kolkata",
|
||||||
"JAVA_OPTS=-Xmx512m -Dserver.use-forward-headers=true -Dserver.context-path=/",
|
"JAVA_OPTS=-Xmx512m -Dserver.use-forward-headers=true -Dserver.context-path=/",
|
||||||
]
|
]
|
||||||
}
|
|
||||||
|
|
||||||
resource "docker_image" "airsonic" {
|
uploads = [
|
||||||
name = "${data.docker_registry_image.airsonic.name}"
|
{
|
||||||
pull_triggers = ["${data.docker_registry_image.airsonic.sha256_digest}"]
|
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")}"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
data "docker_registry_image" "airsonic" {
|
volumes = [
|
||||||
name = "linuxserver/airsonic:latest"
|
{
|
||||||
|
host_path = "/mnt/xwing/config/airsonic2"
|
||||||
|
container_path = "/config"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
host_path = "/mnt/xwing/media/Music"
|
||||||
|
container_path = "/music"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
host_path = "/mnt/xwing/config/airsonic/playlists"
|
||||||
|
container_path = "/playlists"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
host_path = "/mnt/xwing/config/airsonic/podcasts"
|
||||||
|
container_path = "/podcasts"
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
data "template_file" "airsonic-properties-file" {
|
data "template_file" "airsonic-properties-file" {
|
||||||
|
|
|
@ -32,7 +32,8 @@ resource "docker_container" "container" {
|
||||||
memory = "${local.resource["memory"]}"
|
memory = "${local.resource["memory"]}"
|
||||||
|
|
||||||
volumes = "${var.volumes}"
|
volumes = "${var.volumes}"
|
||||||
upload = "${var.uploads}"
|
|
||||||
|
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
|
||||||
|
|
|
@ -91,6 +91,5 @@ variable "volumes" {
|
||||||
|
|
||||||
variable "uploads" {
|
variable "uploads" {
|
||||||
description = "uploads"
|
description = "uploads"
|
||||||
type = "list"
|
|
||||||
default = []
|
default = []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue