I use the following: Apple Macbook Pro M4 Pro (arm64) docker version 4.42.1 Springboot 3.5.4 Springboot Gradle plugin 3.5.4
In latest version of plugin a new error appears when trying to build image using bootBuildImage
task.
I try to build amd64 image on my arm processor and I use the relatively new imagePlatform
property.
When the plugin tries to pull the buildpacks requested and one of them is not found in the builder, it downloads it from docker hub.
In that case the plugin implements the docker calls (in DockerApi class) which are the equivalent of the following docker cli commands:
docker pull --platform <imagePlatform> <buildpack>
docker save <buildpack>
The problem is in the second command implementation, as it doesn't provide the requested platform.
In such case dockerd
decides the platform is the host platform, which in my case is arm64
which doesn't match the pulled image platform.
Hence the plugin sends the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':radius-core:bootBuildImage'.
> Invalid buildpack reference '<buildpack>'
I checked in dockerd related repos, and they do not seem to agree on a solution for the docker save
command issue but require the command to include the --platform
flag in that case.
I think this should also be fixed in Springboot DockerApi class so people with arm processors will be able to build amd images too.
I got an idea of a fix but I'm not sure how to propagate the platform to DockerApi. Can I get help on that matter?
Comment From: wilkinsona
Thanks for the report. Unfortunately, I don't think I understand the problem. The title describes what sounds like a broad problem with bootBuildImage
on Apple Silicon. However, reading the description, it sounds like the problem only occurs when trying to build an amd64
image on an arm64 host. Can you please clarify? Ideally, the clarification would be in the form of a minimal reproducible example that we can run on an Apple Silicon Mac and see it fail in the way that you have described.
Comment From: ofirm93
Sure. He is example app:
The only difference I made from the initial repo generated by spring Initializr is to add to build.gradle
the following gradle plugin configuration:
bootBuildImage {
builder = "paketobuildpacks/builder-noble-java-tiny@sha256:7d2fdc07afb6d54cd5dd61fb466c966dd9f3dc1dd133ffd3714ddf086000b773"
imageName = "demo:v1"
environment = [
"BP_OPENTELEMETRY_ENABLED" : "true",
]
imagePlatform = "linux/amd64"
buildpacks = [
'paketobuildpacks/java',
'paketobuildpacks/opentelemetry:2'
]
}