corda/docker/build.gradle
2019-09-18 10:26:26 +01:00

117 lines
4.1 KiB
Groovy

evaluationDependsOn(":node:capsule")
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'com.bmuschko.docker-remote-api'
// We need to set mainClassName before applying the shadow plugin.
mainClassName = 'net.corda.core.ConfigExporterMain'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
maven {
url "${artifactory_contextUrl}/corda-releases"
}
maven {
url "${artifactory_contextUrl}/corda-dev"
}
}
configurations {
artifactoryCorda
}
dependencies{
compile project(':node')
artifactoryCorda "net.corda:corda:${project.version}"
}
shadowJar {
baseName = 'config-exporter'
classifier = null
version = null
zip64 true
}
docker{
registryCredentials {
url = System.env.DOCKER_URL ?: "hub.docker.com"
username = System.env.DOCKER_USERNAME
password = System.env.DOCKER_PASSWORD
}
}
task buildDockerFolder(dependsOn: [":node:capsule:buildCordaJAR", shadowJar]) {
doLast {
def cordaJar = configurations.artifactoryCorda.singleFile
project.copy {
into new File(project.buildDir, "docker-temp")
from "src/bash/run-corda.sh"
from cordaJar.path
from shadowJar.archivePath
from "src/config/starting-node.conf"
from "src/bash/generate-config.sh"
from "src/docker/DockerfileAL"
from "src/docker/Dockerfile"
from "src/docker/Dockerfile11"
rename(cordaJar.name, "corda.jar")
rename(shadowJar.archivePath.name, "config-exporter.jar")
}
}
}
final String runTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
final String suffix = project.version.toString().toLowerCase().contains("snapshot") ? runTime : "RELEASE"
final zuluBuildTags = ["corda/corda-zulu-java${JavaVersion.current()}-${project.version.toString().toLowerCase()}:${suffix}", "corda/corda-zulu-java${JavaVersion.current()}-${project.version.toString().toLowerCase()}:latest"]
final correttoBuildTags = ["corda/corda-corretto-java${JavaVersion.current()}-${project.version.toString().toLowerCase()}:${suffix}", "corda/corda-corretto-java${JavaVersion.current()}-${project.version.toString().toLowerCase()}:latest"]
task buildOfficialZuluDockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) {
inputDir = new File(project.buildDir, "docker-temp")
tags = zuluBuildTags
dockerFile = new File(new File(project.buildDir, "docker-temp"), "Dockerfile")
}
task buildOfficialZuluJDK11DockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) {
inputDir = new File(project.buildDir, "docker-temp")
tags = zuluBuildTags
dockerFile = new File(new File(project.buildDir, "docker-temp"), "Dockerfile11")
}
task buildOfficialCorrettoDockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) {
inputDir = new File(project.buildDir, "docker-temp")
tags = correttoBuildTags
dockerFile = new File(new File(project.buildDir, "docker-temp"), "DockerfileAL")
}
task pushZuluTimeStampedTag('type': DockerPushImage, dependsOn: [buildOfficialZuluDockerImage]){
imageName = zuluBuildTags[0]
}
task pushZuluLatestTag('type': DockerPushImage, dependsOn: [buildOfficialZuluDockerImage]){
imageName = zuluBuildTags[1]
}
task pushZulu11TimeStampedTag('type': DockerPushImage, dependsOn: [buildOfficialZuluJDK11DockerImage]){
imageName = zuluBuildTags[0]
}
task pushZulu11LatestTag('type': DockerPushImage, dependsOn: [buildOfficialZuluJDK11DockerImage]){
imageName = zuluBuildTags[1]
}
task pushCorrettoTimeStampedTag('type': DockerPushImage, dependsOn: [buildOfficialCorrettoDockerImage]){
imageName = correttoBuildTags[0]
}
task pushCorrettoLatestTag('type': DockerPushImage, dependsOn: [buildOfficialCorrettoDockerImage]){
imageName = correttoBuildTags[1]
}
task pushOfficialImages(dependsOn: [pushZuluTimeStampedTag, pushZuluLatestTag, pushCorrettoTimeStampedTag, pushCorrettoLatestTag])