DockerfileBuilder

Kotlin DSL representation of a Dockerfile.

TODO(Derppening): Unit test the hell out of this

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Enumeration for accepted argument forms in Dockerfile.

Link copied to clipboard

Enumeration of all known instructions as of Docker 19.03.

Link copied to clipboard

Enumeration of available port protocols.

Properties

Link copied to clipboard
private val _lines: MutableList<String>
Link copied to clipboard

Functions

Link copied to clipboard
fun ADD(args: () -> String): DockerfileBuilder

Insert an ADD instruction into the Dockerfile with args as its argument(s).

fun ADD(dest: String, vararg src: String): DockerfileBuilder
fun ADD(form: DockerfileBuilder.Form, dest: String, vararg src: String): DockerfileBuilder
fun ADD(chown: Pair<String, String>, dest: String, vararg src: String): DockerfileBuilder
fun ADD(form: DockerfileBuilder.Form, chown: Pair<String, String>, dest: String, vararg src: String): DockerfileBuilder

Inserts an ADD instruction into the Dockerfile.

Link copied to clipboard

Adds an instruction to the Dockerfile.

Link copied to clipboard
fun ARG(args: () -> String): DockerfileBuilder

Insert an ARG instruction into the Dockerfile with args as its argument(s).

Insert an ARG instruction into the Dockerfile.

Link copied to clipboard
fun build(): Path

Builds this DockerfileBuilder and exports the file to a temporary location.

Link copied to clipboard
open override fun clone(): DockerfileBuilder
Link copied to clipboard
fun CMD(args: () -> String): DockerfileBuilder

Inserts a CMD instruction into the Dockerfile with args as its argument(s).

fun CMD(executable: String, vararg param: String): DockerfileBuilder
fun CMD(form: DockerfileBuilder.Form, executable: String, vararg param: String): DockerfileBuilder

Inserts a CMD instruction into the Dockerfile.

Link copied to clipboard

Adds a comment to the dockerfile.

Link copied to clipboard
fun COPY(args: () -> String): DockerfileBuilder

Insert a COPY instruction into the Dockerfile with args as its argument(s).

fun COPY(dest: String, vararg src: String): DockerfileBuilder
fun COPY(form: DockerfileBuilder.Form, opts: Map<String, String>, dest: String, vararg src: String): DockerfileBuilder

Inserts a COPY instruction into the Dockerfile.

fun COPY(opts: Map<String, String>, dest: String, vararg src: String): DockerfileBuilder

Inserts an COPY instruction into the Dockerfile.

Link copied to clipboard

Insert an ENTRYPOINT instruction into the Dockerfile with args as its argument(s).

fun ENTRYPOINT(executable: String, vararg param: String): DockerfileBuilder
fun ENTRYPOINT(form: DockerfileBuilder.Form, executable: String, vararg param: String): DockerfileBuilder

Insert an ENTRYPOINT instruction into the Dockerfile.

Link copied to clipboard
fun ENV(vararg vars: Pair<String, String>): DockerfileBuilder
fun ENV(key: String, value: String): DockerfileBuilder

Inserts an ENV instruction into the Dockerfile.

fun ENV(args: () -> String): DockerfileBuilder

Inserts an ENV instruction into the Dockerfile with args as its argument(s).

Link copied to clipboard
fun EXPOSE(vararg ports: Int): DockerfileBuilder

Inserts an EXPOSE instruction into the Dockerfile.

fun EXPOSE(args: () -> String): DockerfileBuilder

Inserts an EXPOSE instruction into the Dockerfile with args as its argument(s).

Link copied to clipboard
fun FROM(args: () -> String): DockerfileBuilder

Inserts a FROM instruction into the Dockerfile with args as its argument(s).

fun FROM(image: String, asAlias: String? = null): DockerfileBuilder

Inserts a FROM instruction into the Dockerfile.

Link copied to clipboard

Insert a HEALTHCHECK instruction into the Dockerfile with args as its argument(s).

fun HEALTHCHECK(command: String?, options: String? = null): DockerfileBuilder

Insert a HEALTHCHECK instruction into the Dockerfile.

Link copied to clipboard
private fun <T> Array<T>.joinAsJson(transform: (T) -> CharSequence? = { "\"$it\"" }): String

Joins an Array of objects into a JSON String array.

Link copied to clipboard
private fun <T> Array<T>.joinAsString(transform: (T) -> CharSequence? = null): String

Joins an Array of objects into a space-delimited single string.

Link copied to clipboard
fun LABEL(vararg labels: Pair<String, String>): DockerfileBuilder

Inserts a LABEL instruction into the Dockerfile.

fun LABEL(args: () -> String): DockerfileBuilder

Inserts a LABEL instruction into the Dockerfile with args as its argument(s).

Link copied to clipboard
fun ONBUILD(args: () -> String): DockerfileBuilder

Insert an ONBUILD instruction into the Dockerfile with args as its argument(s).

fun ONBUILD(instruction: String): DockerfileBuilder

Insert an ONBUILD instruction into the Dockerfile.

Link copied to clipboard
fun RUN(args: () -> String): DockerfileBuilder

Inserts a RUN instruction into the Dockerfile with args as its argument(s).

fun RUN(executable: String, vararg param: String): DockerfileBuilder
fun RUN(form: DockerfileBuilder.Form, executable: String, vararg param: String): DockerfileBuilder

Inserts a RUN instruction into the Dockerfile.

Link copied to clipboard
fun SHELL(args: () -> String): DockerfileBuilder

Insert a SHELL instruction into the Dockerfile with args as its argument(s).

fun SHELL(executable: String, vararg parameters: String): DockerfileBuilder

Insert a SHELL instruction into the Dockerfile.

Link copied to clipboard

Insert a STOPSIGNAL instruction into the Dockerfile with args as its argument(s).

Insert a STOPSIGNAL instruction into the Dockerfile.

Link copied to clipboard
fun USER(args: () -> String): DockerfileBuilder

Insert a USER instruction into the Dockerfile with args as its argument(s).

fun USER(uid: Int, gid: Int?): DockerfileBuilder
fun USER(user: String, group: String?): DockerfileBuilder

Insert a USER instruction into the Dockerfile.

Link copied to clipboard
fun VOLUME(vararg volumes: String): DockerfileBuilder

Insert a VOLUME instruction into the Dockerfile.

fun VOLUME(args: () -> String): DockerfileBuilder

Insert a VOLUME instruction into the Dockerfile with args as its argument(s).

Link copied to clipboard
fun WORKDIR(args: () -> String): DockerfileBuilder

Insert an WORKDIR instruction into the Dockerfile with args as its argument(s).

Insert an WORKDIR instruction into the Dockerfile.