Add support for caching to bind mounts when building images

When building an image using the Maven `spring-boot:build-image` goal or
the Gradle `bootBuildImage` task, the build and launch caches can be
configured to use a bind mount as an alternative to using a named
volume.

Closes gh-28387
This commit is contained in:
Scott Frederick
2023-08-21 15:03:39 -05:00
parent d46a58f0f6
commit c17ecf0f0b
25 changed files with 575 additions and 47 deletions

View File

@@ -0,0 +1,24 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
}
java {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.2"
pullPolicy = "IF_NOT_PRESENT"
buildCache {
bind {
source = System.getProperty('java.io.tmpdir') + "/junit-image-cache-${rootProject.name}-build"
}
}
launchCache {
bind {
source = System.getProperty('java.io.tmpdir') + "/junit-image-cache-${rootProject.name}-launch"
}
}
}

View File

@@ -12,10 +12,10 @@ bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.2"
buildCache {
volume {
name = "build-cache-volume1"
name = "build-cache-volume"
}
volume {
name = "build-cache-volum2"
bind {
name = "/tmp/build-cache-bind"
}
}
}