spring-bootbuildpackspring-boot-gradle-pluginpaketo

How to specify target architecture when using Spring Boot gradle task bootBuildImage


I'm trying to build an ARM image on an amd64 node.

This documentation about buildpacks states that I can do it using heroku/builder:24 as the builder image and passing the platform as a parameter --platform linux/arm64

I'm using bootBuildImage gradle task to build my image. I learned how to specify a builder image like:


bootBuildImage {
    archiveFile = war.archiveFile
    if (System.getenv('CI')) {
        builder = "heroku/builder:24"
//...

But I couldn't find any way to pass the platform. Isn't this impossible using the gradle task? Should I revert to building my images using Dockerfiles or using buildpack commands directly?


Solution

  • The future release of Spring Boot, 3.4.0, will provide you with the option to choose the target platform

    https://docs.spring.io/spring-boot/3.4-SNAPSHOT/gradle-plugin/packaging-oci-image.html#build-image.customization

    bootBuildImage {
        imagePlatform = "linux/arm64"
        [etc]
    

    Like @Daniel Mikusa suggested in the comments, you will need a host that can provide an ARM 64 capability; such as Mac Silicons or probably Linux hosts with arm64 emulation enabled and configured in the Docker Daemon