Add option to customize cache volume names when building an image
This commit adds configuration to the Maven and Gradle plugins to allow specifying the names of build and launch cache volumes provided to the CNB builder. See gh-28292
This commit is contained in:
committed by
Scott Frederick
parent
9d6a0cfd24
commit
dc36346285
@@ -181,6 +181,11 @@ The value supplied will be passed unvalidated to Docker when creating the builde
|
||||
| A list of one or more additional tags to apply to the generated image.
|
||||
|
|
||||
|
||||
| `cacheVolumeNames`
|
||||
|
|
||||
| Cache volume names that should be used by the builder instead of generating random names.
|
||||
|
|
||||
|
||||
|===
|
||||
|
||||
NOTE: The plugin detects the target Java compatibility of the project using the JavaPlugin's `targetCompatibility` property.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{gradle-project-version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.ExampleApplication'
|
||||
}
|
||||
|
||||
// tag::cacheVolumeNames[]
|
||||
bootBuildImage {
|
||||
cacheVolumeNames = [
|
||||
"build": "example-build-cachevol",
|
||||
"launch": "example-launch-cachevol"
|
||||
]
|
||||
}
|
||||
// end::cacheVolumeNames[]
|
||||
|
||||
task bootBuildImageCacheVolumeNames {
|
||||
doFirst {
|
||||
bootBuildImage.cacheVolumeNames.each { type, name -> println "$type=$name" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("org.springframework.boot") version "{gradle-project-version}"
|
||||
}
|
||||
|
||||
// tag::cacheVolumeNames[]
|
||||
tasks.getByName<BootBuildImage>("bootBuildImage") {
|
||||
cacheVolumeNames = mapOf("build" to "example-build-cachevol",
|
||||
"launch" to "example-launch-cachevol")
|
||||
}
|
||||
// end::cacheVolumeNames[]
|
||||
|
||||
tasks.register("bootBuildImageEnvironment") {
|
||||
doFirst {
|
||||
for((type, name) in tasks.getByName<BootBuildImage>("bootBuildImage").cacheVolumeNames) {
|
||||
print(type + "=" + name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user