Issue
The maven plugin/goal spring-boot:build-image -Dspring-boot.build-image.builder= when executed cannot find the docker image within the local repo while pack build can
Maven error
mvn clean spring-boot:build-image -Dspring-boot.build-image.builder=redhat/buildpacks-builder-snowdrop-jvm:latest
executing mvnw instead of mvn
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< dev.snowdrop:getting-started >--------------------
[INFO] Building getting-started 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ getting-started ---
[INFO] Deleting /Users/cmoullia/code/snowdrop/snowdrop-buildpacks/apps/snowdrop-sample-app/target
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.4.4:build-image (default-cli) > package @ getting-started >>>
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ getting-started ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/cmoullia/code/snowdrop/snowdrop-buildpacks/apps/snowdrop-sample-app/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /Users/cmoullia/code/snowdrop/snowdrop-buildpacks/apps/snowdrop-sample-app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ getting-started ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/cmoullia/code/snowdrop/snowdrop-buildpacks/apps/snowdrop-sample-app/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ getting-started ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running dev.snowdrop.gettingstarted.GettingStartedApplicationTests
18:29:06.741 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
18:29:06.750 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
...
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ getting-started ---
[INFO] Building jar: /Users/cmoullia/code/snowdrop/snowdrop-buildpacks/apps/snowdrop-sample-app/target/getting-started-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.4:repackage (repackage) @ getting-started ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.4.4:build-image (default-cli) < package @ getting-started <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.4:build-image (default-cli) @ getting-started ---
[INFO] Building image 'docker.io/library/getting-started:0.0.1-SNAPSHOT'
[INFO]
[INFO] > Pulling builder image 'docker.io/redhat/buildpacks-builder-snowdrop-jvm:latest' 100%
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.149 s
[INFO] Finished at: 2021-03-30T18:29:12+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:build-image (default-cli) on project getting-started: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:build-image failed: Docker API call to 'localhost/v1.24/images/create?fromImage=docker.io%2Fredhat%2Fbuildpacks-builder-snowdrop-jvm%3Alatest' failed with status code 404 "Not Found" -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Pack build
pack build snowdrop/demo/hello --path . --builder redhat/buildpacks-builder-snowdrop-jvm
0.10.2: Pulling from buildpacksio/lifecycle
Digest: sha256:c3a070ed0eaf8776b66f9f7c285469edccf5299b3283c453dd45699d58d78003
Status: Image is up to date for buildpacksio/lifecycle:0.10.2
===> DETECTING
[detector] dev.snowdrop.buildpacks.buildpack 0.0.1
===> ANALYZING
[analyzer] Restoring metadata for "dev.snowdrop.buildpacks.buildpack:0-ubiconfig" from app image
[analyzer] Restoring metadata for "dev.snowdrop.buildpacks.buildpack:1-app" from app image
[analyzer] Restoring metadata for "dev.snowdrop.buildpacks.buildpack:2-app" from app image
[analyzer] Restoring metadata for "dev.snowdrop.buildpacks.buildpack:m2repo" from cache
===> RESTORING
[restorer] Restoring data for "dev.snowdrop.buildpacks.buildpack:m2repo" from cache
^CERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: context canceled
Info
Spring Boot version used: 2.4.4 Builder project and script used to build .... buildpacks: https://github.com/snowdrop/snowdrop-buildpacks/blob/2cf05844f35226c07a5df7fea88396caf4c955a2/create-buildpacks.sh
Comment From: scottfrederick
The Spring Boot plugins and the pack CLI both support image pull policy configuration with options for "always", "never", and "if not present". They are also consistent with the the default value being "always". The difference that you have shown between these tools is that the Spring Boot plugins fail when the pull policy is "always" but the image does not exist in the remote repository, while pack will detect this condition and use a local image if it does not exist in the remote repository.
As a workaround, you can configure the pull policy in the Spring Boot Maven plugin to use <pullPolicy>IF_NOT_PRESENT</pullPolicy>.
We can use this issue to enhance the Spring Boot plugins to be more forgiving and align with pack behavior.
Comment From: cmoulliard
We can use this issue to enhance the Spring Boot plugins to be more forgiving and align with
packbehavior.
Excellent idea :-)
Comment From: cmoulliard
As a workaround, you can configure the pull policy in the Spring Boot Maven plugin to use
<pullPolicy>IF_NOT_PRESENT</pullPolicy>.
Many thanks for the trick. That works now even if I got a new error.
[INFO] --- spring-boot-maven-plugin:2.4.4:build-image (default-cli) @ getting-started ---
[INFO] Building image 'docker.io/library/getting-started:0.0.1-SNAPSHOT'
[INFO]
[INFO] > Executing lifecycle version v0.10.2
[INFO] > Using build cache volume 'pack-cache-546151ed77df.build'
[INFO]
[INFO] > Running creator
[INFO] [creator] ===> DETECTING
[INFO] [creator] ERROR: No buildpack groups passed detection.
[INFO] [creator] ERROR: Please check that you are running against the correct path.
[INFO] [creator] ERROR: failed to detect: no buildpacks participating
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.963 s
[INFO] Finished at: 2021-03-30T20:36:39+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:build-image (default-cli) on project getting-started:
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.4:build-image failed:
Builder lifecycle 'creator' failed with status code 100 -> [Help 1]
[ERROR]
Comment From: scottfrederick
The ERROR: No buildpack groups passed detection. condition is outside of Spring Boot's control. At least one buildpack group in the builder must pass detection. When using a composite buildpack, all non-optional buildpacks in the group must pass detection in order for the entire group to pass detection.
Comment From: cmoulliard
In fact we observe a different behavior using pack build vs mvn spring-boot:build-image as spring is performing the detect phase under the built folder while pack under the source of the project and then the pom file cannot be retrieve
[INFO] [creator] ======== Output: dev.snowdrop.buildpacks.buildpack@0.0.1 ========
[INFO] [creator] + echo '- Testing for Pom:'
[INFO] [creator] - Testing for Pom:
[INFO] [creator] + [[ ! -f pom.xml ]]
[INFO] [creator] + exit 100
[INFO] [creator] ======== Results ========
[INFO] [creator] + ls -la
[INFO] [creator] total 20
[INFO] [creator] drwxr-xr-x 5 jboss jboss 4096 Mar 30 19:44 .
[INFO] [creator] drwxr-xr-x 1 root root 4096 Mar 30 19:44 ..
[INFO] [creator] drwxr-xr-x 4 jboss jboss 4096 Jan 1 1980 BOOT-INF
[INFO] [creator] drwxr-xr-x 3 jboss jboss 4096 Jan 1 1980 META-INF
[INFO] [creator] drwxr-xr-x 3 jboss jboss 4096 Jan 1 1980 org
Comment From: scottfrederick
The Spring Boot Maven plugin will always provide the packaged jar contents to the builder. With pack build you can choose to either provide the application source (for example, from the root folder containing pom.xml) or provide a pre-built jar file (for example, from ./target/getting-started-0.0.1-SNAPSHOT.jar). This difference is by design, as we don't believe it makes sense for the Spring Boot Maven plugin to send the source code to a builder so it can be built by Maven in the buildpack.
This issue is straying from the original problem report into other areas of Spring Boot and pack behavior. We'd prefer to keep this type of discussion out of GitHub issues and use Gitter and StackOverflow instead.
Comment From: cmoulliard
This issue is straying from the original problem report into other areas of Spring Boot and
packbehavior. We'd prefer to keep this type of discussion out of GitHub issues and use Gitter and StackOverflow instead.
I agree :-)
Comment From: cmoulliard
The Spring Boot Maven plugin will always provide the packaged jar contents to the builder
Are the Spring developers aware of that ? Is it documented ?
Comment From: wilkinsona
Yes, we are aware. As you can tell from his profile and contributions, Scott is a Spring developer and he has just described the behaviour. It's documented here:
The plugin can create an OCI image from an executable jar file using Cloud Native Buildpacks (CNB)
Now let's keep this issue on topic, please, as Scott already requested above.