io.bkbn.skelegro.docker.Dockerfile.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of skelegro-docker Show documentation
Show all versions of skelegro-docker Show documentation
A wacky assortment of Kotlin DSLs for infrastructure manifest generation
package io.bkbn.skelegro.docker
import io.bkbn.skelegro.docker.commands.Command
import io.bkbn.skelegro.docker.commands.From
import java.util.ArrayList
open class Dockerfile(var from: From? = null, var steps: ArrayList = arrayListOf()) : IDockerfile {
private fun buildDockerfile(build: StringBuilder.() -> Unit): String {
val stringBuilder = StringBuilder()
stringBuilder.build()
return stringBuilder.toString().trim()
}
override fun toString(): String {
return buildDockerfile {
if (!from?.comment.isNullOrBlank()) appendLine("# ${from?.comment}")
appendLine(from)
steps.forEach {
if (!it.comment.isNullOrBlank()) appendLine("# ${it.comment}")
appendLine(it.toString())
}
}
}
}
fun docker(init: Dockerfile.() -> Unit): Dockerfile {
val dockerfile = Dockerfile()
dockerfile.init()
return dockerfile
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy