spring-bootgradlecontainersoracle-call-interfacebuildpack

gradle spring-boot 2.3.0.M3 buildpack with builder --builder cloudfoundry/cnb:bionic cache jdk not to download on every run


I have a spring-boot gradle REST app and want to create an OCI conformant image with https://buildpacks.io/ pack

pack -v build minimal_rest --builder cloudfoundry/cnb:bionic

on any execution it re-downloads the jdk as "Contributing to layer"

===> BUILDING
[builder]
[builder] Cloud Foundry OpenJDK Buildpack v1.2.14
[builder]   OpenJDK JDK 11.0.6: Contributing to layer
[builder]     Downloading from https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%!B(MISSING)10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.6_10.tar.gz

is there a way to "cache" contributing layers, so that they are not re-downloaded on every run?

plus:

I use spring-boot-starter-2.3.0.M3 and gradle 6.2.1 with org.springframework.boot plugin (also v 2.3.0.M3)

on calling

./gradlew clean build -x test bootBuildImage

with

tasks {
    bootJar {
        val archivesBaseName: String by project.extra
        archiveBaseName.set(archivesBaseName)
        manifest {
            attributes["Implementation-Title"] = project.name
            attributes["Implementation-Version"] = v.version
            attributes["provider"] = "gradle"
        }
    }
    bootBuildImage {
        builder = "cloudfoundry/cnb:bionic"
        val archivesBaseName: String by project.extra
        imageName = archivesBaseName
    }
}

I finally get:

Execution failed for task ':bootBuildImage'.
> Detected platform API version 'v0.3' is not included in supported versions 'v0.1,v0.2'

but using the cloudfoundry/cnb:bionic that is just 2 days old (20th march 2020)

maybe any ideas on that also?


Solution

  • so I got an answer on their slack channel (at least for the first part).

    After a non-errored run with --clear-cache ... pack now caches the jdk and does not download the jdk on every run. (for sure not passing --clear-cache on consecutive runs)

    also while in your project root dir you can ask pack itself which builders it "recommends" with:

    $ pack suggest-builders
    Suggested builders:
        Cloud Foundry:     cloudfoundry/cnb:bionic         Ubuntu bionic base image with buildpacks for Java, NodeJS and Golang
        Cloud Foundry:     cloudfoundry/cnb:cflinuxfs3     cflinuxfs3 base image with buildpacks for Java, .NET, NodeJS, Python, Golang, PHP, HTTPD and NGINX
        Cloud Foundry:     cloudfoundry/cnb:tiny           Tiny base image (bionic build image, distroless run image) with buildpacks for Golang
        Heroku:            heroku/buildpacks:18            heroku-18 base image with buildpacks for Ruby, Java, Node.js, Python, Golang, & PHP
    
    Tip: Learn more about a specific builder with:
        pack inspect-builder [builder image]
    ```