I'm using Spring boot plugin 3.1.0
build.gradle.kts:
tasks.named<BootBuildImage>("bootBuildImage") {
tags.add("europe-west1-docker.pkg.dev/my-project/my-docker-registry/${project.name}:$version")
imageName.set("europe-west1-docker.pkg.dev/my-project/my-docker-registry/${project.name}:$version")
}
during the run, it hangs for several minutes and fails:
* What went wrong:
Execution failed for task ':bootBuildImage'.
> Unable to parse image reference "europe-west1-docker.pkg.dev/my-project/my-docker-registry/app:9.9.9". Image reference must be in the form '[domainHost:port/][path/]name[:tag][@digest]', with 'path' and 'name' containing only [a-z0-9][.][_][-]
It is strange enough, but it fails only if this is configured in a gradle script, but it works fine if the same tag is passed as a parameter:
./gradlew bootBuildImage --image-name=europe-west1-docker.pkg.dev/my-project/my-docker-registry/app:9.9.9
Comment From: scottfrederick
I can't reproduce what you are describing with a trivial application generated by start.spring.io and configured as you've shown. Please provide a complete minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it and attaching it to this issue.
Comment From: mfarsikov
Reproducible repo: https://github.com/mfarsikov/bootBuildImage-reproduce
It is really strange, it highly depends on any change in a string.
I have found an error in my script: I was using $name (instead of ${project.name}) which resolves to task name bootBuildImage (which is still a valid name for a container). Using ${project.name} it does not reproduce.
Comment From: scottfrederick
Thanks for the reproducer. I see that it takes some time to show the failure message with the bootBuildImage in the name.
I was using
$name(instead of${project.name}) which resolves to task namebootBuildImage(which is still a valid name for a container).
bootBuildImage is not a valid name. From the Docker reference:
PATH: The path consists consists of slash-separated components. Each component may contain lowercase letters, digits and separators.
The upper-case letters are not valid, which is reflected in the error message from the Spring Boot plugin (Image reference must be in the form '[domainHost:port/][path/]name[:tag][@digest]', with 'path' and 'name' containing only [a-z0-9][.][_][-]).
We can look at what is causing the delay (I suspect it has to do with the regular expressions we use for parsing) but I assume things are working OK for you when the image name is valid, so this is not preventing you from building images?
Comment From: mfarsikov
You are right, after giving it the correct name it works fine. Thank you