Set up influxdb

This commit is contained in:
2024-11-08 13:05:05 +01:00
parent ec76048ee0
commit 29f1560272
5 changed files with 88 additions and 6 deletions

View File

@@ -1,4 +1,8 @@
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
import java.lang.System.getenv
plugins {
alias(hlaeja.plugins.com.bmuschko.docker)
alias(hlaeja.plugins.kotlin.jvm)
alias(hlaeja.plugins.kotlin.spring)
alias(hlaeja.plugins.ltd.hlaeja.plugin.service)
@@ -7,6 +11,7 @@ plugins {
}
dependencies {
implementation(hlaeja.com.influxdb.client.kotlin)
implementation(hlaeja.kotlin.reflect)
implementation(hlaeja.kotlinx.coroutines)
implementation(hlaeja.org.springframework.springboot.actuator.starter)
@@ -22,3 +27,22 @@ dependencies {
}
group = "ltd.hlaeja"
tasks {
}
fun influxDbToken(): String = if (extra.has("influxdb.token")) {
extra["influxdb.token"] as String
} else {
getenv("INFLUXDB_TOKEN") ?: "missing_token"
}
tasks {
named("containerCreate", DockerCreateContainer::class) {
withEnvVar("INFLUXDB_TOKEN", influxDbToken())
}
withType<ProcessResources> {
filesMatching("**/application.yml") { filter { it.replace("%INFLUXDB_TOKEN%", influxDbToken()) } }
onlyIf { file("src/main/resources/application.yml").exists() }
}
}