Add support for build workspace option when building images
Closes gh-37478
This commit is contained in:
@@ -193,14 +193,22 @@ The value supplied will be passed unvalidated to Docker when creating the builde
|
||||
The values provided to the `tags` option should be full image references in the form of `[image name]:[tag]` or `[repository]/[image name]:[tag]`.
|
||||
|
|
||||
|
||||
| `buildWorkspace`
|
||||
|
|
||||
| A temporary workspace that will be used by the builder and buildpacks to store files during image building.
|
||||
The value can be a named volume or a bind mount location.
|
||||
| A named volume in the Docker daemon, with a name derived from the image name.
|
||||
|
||||
| `buildCache`
|
||||
|
|
||||
| A cache containing layers created by buildpacks and used by the image building process.
|
||||
The value can be a named volume or a bind mount location.
|
||||
| A named volume in the Docker daemon, with a name derived from the image name.
|
||||
|
||||
| `launchCache`
|
||||
|
|
||||
| A cache containing layers created by buildpacks and used by the image launching process.
|
||||
The value can be a named volume or a bind mount location.
|
||||
| A named volume in the Docker daemon, with a name derived from the image name.
|
||||
|
||||
| `createdDate`
|
||||
@@ -420,7 +428,7 @@ The publish option can be specified on the command line as well, as shown in thi
|
||||
----
|
||||
|
||||
[[build-image.examples.caches]]
|
||||
=== Builder Cache Configuration
|
||||
=== Builder Cache and Workspace Configuration
|
||||
|
||||
The CNB builder caches layers that are used when building and launching an image.
|
||||
By default, these caches are stored as named volumes in the Docker daemon with names that are derived from the full name of the target image.
|
||||
@@ -440,7 +448,10 @@ include::../gradle/packaging/boot-build-image-caches.gradle[tags=caches]
|
||||
include::../gradle/packaging/boot-build-image-caches.gradle.kts[tags=caches]
|
||||
----
|
||||
|
||||
The caches can be configured to use bind mounts instead of named volumes, as shown in the following example:
|
||||
Builders and buildpacks need a location to store temporary files during image building.
|
||||
By default, this temporary build workspace is stored in a named volume.
|
||||
|
||||
The caches and the build workspace can be configured to use bind mounts instead of named volumes, as shown in the following example:
|
||||
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
|
||||
@@ -9,6 +9,11 @@ tasks.named("bootJar") {
|
||||
|
||||
// tag::caches[]
|
||||
tasks.named("bootBuildImage") {
|
||||
buildWorkspace {
|
||||
bind {
|
||||
source = "/tmp/cache-${rootProject.name}.work"
|
||||
}
|
||||
}
|
||||
buildCache {
|
||||
bind {
|
||||
source = "/tmp/cache-${rootProject.name}.build"
|
||||
@@ -24,6 +29,7 @@ tasks.named("bootBuildImage") {
|
||||
|
||||
tasks.register("bootBuildImageCaches") {
|
||||
doFirst {
|
||||
bootBuildImage.buildWorkspace.asCache().with { print "buildWorkspace=$source" }
|
||||
bootBuildImage.buildCache.asCache().with { println "buildCache=$source" }
|
||||
bootBuildImage.launchCache.asCache().with { println "launchCache=$source" }
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@ plugins {
|
||||
|
||||
// tag::caches[]
|
||||
tasks.named<BootBuildImage>("bootBuildImage") {
|
||||
buildWorkspace {
|
||||
bind {
|
||||
source.set("/tmp/cache-${rootProject.name}.work")
|
||||
}
|
||||
}
|
||||
buildCache {
|
||||
bind {
|
||||
source.set("/tmp/cache-${rootProject.name}.build")
|
||||
@@ -22,6 +27,7 @@ tasks.named<BootBuildImage>("bootBuildImage") {
|
||||
|
||||
tasks.register("bootBuildImageCaches") {
|
||||
doFirst {
|
||||
println("buildWorkspace=" + tasks.getByName<BootBuildImage>("bootBuildImage").buildWorkspace.asCache().bind.source)
|
||||
println("buildCache=" + tasks.getByName<BootBuildImage>("bootBuildImage").buildCache.asCache().bind.source)
|
||||
println("launchCache=" + tasks.getByName<BootBuildImage>("bootBuildImage").launchCache.asCache().bind.source)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user