Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to create a container from jar #37

Closed
eddumelendez opened this issue May 25, 2020 · 8 comments
Closed

Add support to create a container from jar #37

eddumelendez opened this issue May 25, 2020 · 8 comments
Assignees
Labels
kind/enhancement New feature or request lang/java Java Buildpacks

Comments

@eddumelendez
Copy link

Currently, spring-boot supports image customization via maven or gradle in the latest snapshots get

[INFO] Building image 'docker.io/library/demo:0.0.1-SNAPSHOT'
[INFO]
[INFO]  > Pulling builder image 'gcr.io/buildpacks/builder:latest' 100%
[INFO]  > Pulled builder image 'gcr.io/buildpacks/builder@sha256:efb5f9b7cd976ab6e5a959f453795863a476878be8e5c20b50db22c8aec1227f'
[INFO]  > Pulling run image 'gcr.io/buildpacks/gcp/run:latest' 100%
[INFO]  > Pulled run image 'gcr.io/buildpacks/gcp/run@sha256:9b3973dd6765f88815318454e337b7f5aacf25cf27f3038be49ef18cf6fce3b1'
[INFO]  > Executing lifecycle version v0.7.5
[INFO]  > Using build cache volume 'pack-cache-5cbe5692dbc4.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: failed to detect: no buildpacks participating

and this is due to spring-boot already build the jar so the builder is not able to detect the jar produced. I think will be nice to have this.

Originally posted by @eddumelendez in #32 (comment)

@lukasberger
Copy link
Collaborator

Thank you for the report. We do support creating containers from jar files, but only from the project root at the moment. What is the structure of the directory that spring-boot calls the build from?

@lukasberger lukasberger added kind/enhancement New feature or request lang/java Java Buildpacks labels May 26, 2020
@eddumelendez
Copy link
Author

eddumelendez commented May 26, 2020

for maven projects the jar is inside root-project -> target -> file.jar and for gradle is root-project -> build -> libs -> file.jar

@ashih
Copy link
Collaborator

ashih commented May 26, 2020

Our buildpacks work with springboot [1] and do support searching in the generated directory for jars [2]. What exactly is your request? Can you provide some sort of code sample and step-by-step instructions on the commands you are trying to run. Thanks!

[1] https://github.com/GoogleCloudPlatform/buildpacks/tree/master/builders/testdata/java/springboot-helloworld
[2] https://github.com/GoogleCloudPlatform/buildpacks/blob/master/pkg/java/java.go#L49

@lukasberger
Copy link
Collaborator

I believe the java/runtime buildpack is at fault here. Even though we look for jars in both maven and gradle output directories in the java/entrypoint buildpack, the java/runtime buildpack does not look for nested jars and opts out, failing the build.

@eddumelendez
Copy link
Author

eddumelendez commented May 26, 2020

examples are attached. They are generated from start.spring.io with the latest snapshots only. no other changes are required.

In order to run gradle-demo: ./gradlew bootBuildImage --builder=gcr.io/buildpacks/builder

In order to run maven-demo:./mvnw spring-boot:build-image -DskipTests -Dspring-boot.build-image.builder=gcr.io/buildpacks/builder

Both generate the error message ERROR: No buildpack groups passed detection.

maven-demo.zip

gradle-demo.zip

@eddumelendez
Copy link
Author

I have enabled the logging and this is the result. Instructions in the previous comment

[INFO]  > Running creator
[INFO]     [creator]     ---> DETECTING
[INFO]     [creator]     ======== Output: google.dotnet.functions-framework@0.0.1 ========
[INFO]     [creator]     GOOGLE_FUNCTION_TARGET not set
[INFO]     [creator]     ======== Output: google.dotnet.runtime@0.9.0 ========
[INFO]     [creator]     No project files nor .dll files found.
[INFO]     [creator]     ======== Output: google.dotnet.publish@0.9.0 ========
[INFO]     [creator]     no project file found and GOOGLE_BUILDABLE not set.
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     skip: google.dotnet.functions-framework@0.0.1
[INFO]     [creator]     fail: google.dotnet.runtime@0.9.0
[INFO]     [creator]     fail: google.dotnet.publish@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.dotnet.runtime@0.9.0 ========
[INFO]     [creator]     No project files nor .dll files found.
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.dotnet.runtime@0.9.0
[INFO]     [creator]     fail: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.go.runtime@0.9.0 ========
[INFO]     [creator]     No *.go files found.
[INFO]     [creator]     ======== Output: google.go.functions-framework@0.9.0 ========
[INFO]     [creator]     GOOGLE_FUNCTION_TARGET not set
[INFO]     [creator]     ======== Output: google.go.build@0.9.0 ========
[INFO]     [creator]     No *.go files found
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Output: google.go.clear_source@0.9.0 ========
[INFO]     [creator]     GOOGLE_CLEAR_SOURCE not set
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.go.runtime@0.9.0
[INFO]     [creator]     fail: google.go.functions-framework@0.9.0
[INFO]     [creator]     fail: google.go.build@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     skip: google.go.clear_source@0.9.0
[INFO]     [creator]     ======== Output: google.go.runtime@0.9.0 ========
[INFO]     [creator]     No *.go files found.
[INFO]     [creator]     ======== Output: google.go.build@0.9.0 ========
[INFO]     [creator]     No *.go files found
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Output: google.go.clear_source@0.9.0 ========
[INFO]     [creator]     GOOGLE_CLEAR_SOURCE not set
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.go.runtime@0.9.0
[INFO]     [creator]     pass: google.go.gopath@0.9.0
[INFO]     [creator]     fail: google.go.build@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     skip: google.go.clear_source@0.9.0
[INFO]     [creator]     ======== Output: google.java.runtime@0.9.0 ========
[INFO]     [creator]     None of the following found: pom.xml, build.gradle, build.gradle.kts, *.java, *.jar.
[INFO]     [creator]     ======== Output: google.java.maven@0.9.0 ========
[INFO]     [creator]     pom.xml not found.
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.java.runtime@0.9.0
[INFO]     [creator]     fail: google.java.maven@0.9.0
[INFO]     [creator]     fail: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.java.runtime@0.9.0 ========
[INFO]     [creator]     None of the following found: pom.xml, build.gradle, build.gradle.kts, *.java, *.jar.
[INFO]     [creator]     ======== Output: google.java.maven@0.9.0 ========
[INFO]     [creator]     pom.xml not found.
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.java.runtime@0.9.0
[INFO]     [creator]     fail: google.java.maven@0.9.0
[INFO]     [creator]     pass: google.java.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.java.runtime@0.9.0 ========
[INFO]     [creator]     None of the following found: pom.xml, build.gradle, build.gradle.kts, *.java, *.jar.
[INFO]     [creator]     ======== Output: google.java.gradle@0.9.0 ========
[INFO]     [creator]     Neither build.gradle nor build.gradle.kts found.
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.java.runtime@0.9.0
[INFO]     [creator]     skip: google.java.gradle@0.9.0
[INFO]     [creator]     fail: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.java.runtime@0.9.0 ========
[INFO]     [creator]     None of the following found: pom.xml, build.gradle, build.gradle.kts, *.java, *.jar.
[INFO]     [creator]     ======== Output: google.java.gradle@0.9.0 ========
[INFO]     [creator]     Neither build.gradle nor build.gradle.kts found.
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.java.runtime@0.9.0
[INFO]     [creator]     skip: google.java.gradle@0.9.0
[INFO]     [creator]     pass: google.java.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.python.runtime@0.9.0 ========
[INFO]     [creator]     No *.py files found.
[INFO]     [creator]     ======== Output: google.python.functions-framework@0.9.0 ========
[INFO]     [creator]     GOOGLE_FUNCTION_TARGET not set
[INFO]     [creator]     ======== Output: google.python.pip@0.9.0 ========
[INFO]     [creator]     requirements.txt not found
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.python.runtime@0.9.0
[INFO]     [creator]     fail: google.python.functions-framework@0.9.0
[INFO]     [creator]     skip: google.python.pip@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.python.runtime@0.9.0 ========
[INFO]     [creator]     No *.py files found.
[INFO]     [creator]     ======== Output: google.python.pip@0.9.0 ========
[INFO]     [creator]     requirements.txt not found
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.python.runtime@0.9.0
[INFO]     [creator]     skip: google.python.pip@0.9.0
[INFO]     [creator]     fail: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.nodejs.runtime@0.9.0 ========
[INFO]     [creator]     package.json not found and no *.js files found
[INFO]     [creator]     ======== Output: google.nodejs.yarn@0.9.0 ========
[INFO]     [creator]     yarn.lock not found.
[INFO]     [creator]     ======== Output: google.nodejs.functions-framework@0.9.0 ========
[INFO]     [creator]     GOOGLE_FUNCTION_TARGET not set
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.nodejs.runtime@0.9.0
[INFO]     [creator]     fail: google.nodejs.yarn@0.9.0
[INFO]     [creator]     skip: google.nodejs.functions-framework@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.nodejs.runtime@0.9.0 ========
[INFO]     [creator]     package.json not found and no *.js files found
[INFO]     [creator]     ======== Output: google.nodejs.npm@0.9.0 ========
[INFO]     [creator]     package.json not found.
[INFO]     [creator]     ======== Output: google.nodejs.functions-framework@0.9.0 ========
[INFO]     [creator]     GOOGLE_FUNCTION_TARGET not set
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.nodejs.runtime@0.9.0
[INFO]     [creator]     fail: google.nodejs.npm@0.9.0
[INFO]     [creator]     skip: google.nodejs.functions-framework@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.nodejs.runtime@0.9.0 ========
[INFO]     [creator]     package.json not found and no *.js files found
[INFO]     [creator]     ======== Output: google.nodejs.functions-framework@0.9.0 ========
[INFO]     [creator]     GOOGLE_FUNCTION_TARGET not set
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.nodejs.runtime@0.9.0
[INFO]     [creator]     fail: google.nodejs.functions-framework@0.9.0
[INFO]     [creator]     skip: google.config.entrypoint@0.9.0
[INFO]     [creator]     ======== Output: google.nodejs.runtime@0.9.0 ========
[INFO]     [creator]     package.json not found and no *.js files found
[INFO]     [creator]     ======== Output: google.config.entrypoint@0.9.0 ========
[INFO]     [creator]     GOOGLE_ENTRYPOINT not set and Procfile not found
[INFO]     [creator]     ======== Results ========
[INFO]     [creator]     fail: google.nodejs.runtime@0.9.0
[INFO]     [creator]     fail: google.config.entrypoint@0.9.0
[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: failed to detect: no buildpacks participating

@scottfrederick
Copy link

We do support creating containers from jar files, but only from the project root at the moment.

Even though we look for jars in both maven and gradle output directories in the java/entrypoint buildpack

The Spring Boot plugins for Maven and Gradle will only provide a jar file to the CNB builder when the image-building features are used (e.g. with the mvn spring-boot:build-image goal or gradle bootBuildImage task). This is the equivalent of only providing a jar file as the target with the pack build CLI command. For example, with a Gradle-built project the pack build command to build an image from a jar file would be:

$ pack build docker.io/library/demo:0.1 --builder <builder-image-name> --path build/libs/demo-0.0.1-SNAPSHOT.jar

If buildpacks only support detection of jar files in known locations from the project root, then they won't work with Spring Boot's Maven and Gradle plugins. The gist of this issue is to consider adding the ability to detect a Java application from only a jar file as an option in the Google Cloud Platform buildpacks.

@lukasberger
Copy link
Collaborator

The java/runtime buildpack will currently not pass detection unless the jar file is at application root, however, builds still fail after updating the logic. It looks like Spring Boot runs the build with an exploded jar, which we do not support yet, i.e.

./META-INF/MANIFEST.MF
./org/springframework/boot/...
./BOOT-INF/classpath.idx
./BOOT-INF/lib/...
./BOOT-INF/classes/...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request lang/java Java Buildpacks
Projects
None yet
Development

No branches or pull requests

4 participants