mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Gradle: Generalize docker build task
This commit is contained in:
parent
86a359426d
commit
aa984e6972
@ -1,23 +1,27 @@
|
||||
package bisq.gradle.docker.image_builder
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
abstract class DockerBuildTask : DefaultTask() {
|
||||
|
||||
@get:InputDirectory
|
||||
abstract val dockerDirectory: Property<File>
|
||||
abstract val dockerDirectory: DirectoryProperty
|
||||
|
||||
@get:Input
|
||||
abstract val imageTag: Property<String>
|
||||
|
||||
@TaskAction
|
||||
fun build() {
|
||||
val processBuilder = ProcessBuilder(
|
||||
"docker", "build",
|
||||
"--tag", "bisq/seednode:latest",
|
||||
dockerDirectory.get().absolutePath
|
||||
"--tag", imageTag.get(),
|
||||
dockerDirectory.asFile.get().absolutePath
|
||||
)
|
||||
|
||||
processBuilder.redirectErrorStream(true)
|
||||
|
@ -20,9 +20,10 @@ class DockerImageBuilderPlugin : Plugin<Project> {
|
||||
val installDistTask: TaskProvider<Sync> = project.tasks.named("installDist", Sync::class.java)
|
||||
val distTarTask: TaskProvider<Tar> = project.tasks.named("distTar", Tar::class.java)
|
||||
|
||||
val seednodeBuildDir = project.layout.buildDirectory.dir("docker")
|
||||
val copyTask = project.tasks.register<Copy>("copyDistTar") {
|
||||
from(distTarTask.flatMap { it.archiveFile })
|
||||
into(project.layout.buildDirectory.dir("docker"))
|
||||
into(seednodeBuildDir)
|
||||
}
|
||||
|
||||
project.tasks.register<CreateDockerfileTask>("generateDockerfile") {
|
||||
@ -38,8 +39,10 @@ class DockerImageBuilderPlugin : Plugin<Project> {
|
||||
outputFile.set(project.layout.buildDirectory.file("docker/Dockerfile"))
|
||||
}
|
||||
|
||||
project.tasks.register<DockerBuildTask>("dockerImage") {
|
||||
dockerDirectory.set(copyTask.map { it.destinationDir })
|
||||
project.tasks.register<DockerBuildTask>("seednodeDockerImage") {
|
||||
dependsOn(copyTask)
|
||||
imageTag.set("bisq/seednode:latest")
|
||||
dockerDirectory.set(seednodeBuildDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user