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