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 Oliver bp-native profile #121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anthonydahanne
Copy link

@anthonydahanne anthonydahanne commented Apr 5, 2024

  • Comment out native profile customization, so that the default one provided by spring boot parent can add its required <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE> to the spring boot plugin

  • Comment out the spring-boot-maven-plugin customization

    • that turns the jar into an "executable" (<executable>true</executable>) that makes the jar no longer a jar (and hence can't be properly detected by BP)
  • that uses the spring boot thin layout that removes the Spring-Boot-Lib from the manifest which is required for BP detection

Now using ./mvnw -Pnative,native-bp BP will do the native build; I've tested it, it works fine

2024-04-05T17:50:24.251Z  INFO 1 --- [restbucks] [           main] org.springsource.restbucks.Restbucks     : Started Restbucks in 0.377 seconds (process running for 0.411)

Replacing java-native-image:beta with java:beta, and running ./mvnw -Pnative-bp should also work for a regular jar

* Comment out native profile customization, so that the default one provided by spring boot parent can add its required                     <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE> tot he spring boot plugin

* Comment out the spring-boot-maven-plugin customization
 - that turns the jar into an "executable" (<executable>true</executable>) that makes the jar no longer a jar (and hence can't be properly detected by BP)
 - that uses the spring boot thin layout that removes the Spring-Boot-Lib from the manifest which is required for BP detection

 Now using ./mvnw -Pnative,native-bp BP will do the native build; I've tested it, it works fine

 ```
 2024-04-05T17:50:24.251Z  INFO 1 --- [restbucks] [           main] org.springsource.restbucks.Restbucks     : Started Restbucks in 0.377 seconds (process running for 0.411)
 ```

 Replacing java-native-image:beta with java:beta, and running ./mvnw -Pnative-bp should also work for a regular jar
@odrotbohm
Copy link
Owner

I tried applying your changes on current main, tweaked the Java version back to 21, but still get this error:

[INFO] --- spring-boot-maven-plugin:3.3.0-M3:build-image (default-cli) @ restbucks ---
[INFO] Building image 'docker.io/library/restbucks:1.0.0.BUILD-SNAPSHOT'
[INFO] 
[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-buildpackless-tiny:latest' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder-jammy-buildpackless-tiny@sha256:7a10bca287d2fe876a8f76c3d312b973aa0d73f03823b031d149958652803533'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run-jammy-tiny:latest' 100%
[INFO]  > Pulled run image 'paketobuildpacks/run-jammy-tiny@sha256:683d960443ba88d5eb452c62d5af70741c6ea879f37f9680fc207494d45d8980'
[INFO]  > Pulling buildpack image 'docker.io/paketobuildpacks/java-native-image:beta' 100%
[INFO]  > Pulled buildpack image 'paketobuildpacks/java-native-image@sha256:983232987d74290ded4134b3f75e81e24550223fed56732772e5b27fa882e866'
[INFO]  > Executing lifecycle version v0.19.2
[INFO]  > Using build cache volume 'pack-cache-43e5c9f766a8.build'
[INFO] 
[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Restoring data for SBOM from previous image
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 15 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.7.0
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.6.0
[INFO]     [creator]     paketo-buildpacks/syft              1.46.0
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.9.0
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.28.0
[INFO]     [creator]     paketo-buildpacks/native-image      5.13.0
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
[INFO]     [creator]     Restoring metadata for "paketo-buildpacks/bellsoft-liberica:native-image-svm" from cache
[INFO]     [creator]     Restoring metadata for "paketo-buildpacks/syft:syft" from cache
[INFO]     [creator]     Restoring metadata for "paketo-buildpacks/native-image:native-image" from cache
[INFO]     [creator]     Restoring data for "paketo-buildpacks/bellsoft-liberica:native-image-svm" from cache
[INFO]     [creator]     Restoring data for "paketo-buildpacks/syft:syft" from cache
[INFO]     [creator]     Restoring data for "paketo-buildpacks/native-image:native-image" from cache
[INFO]     [creator]     Restoring data for SBOM from cache
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.7.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/ca-certificates
[INFO]     [creator]       Launch Helper: Contributing to layer
[INFO]     [creator]         Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for BellSoft Liberica 10.6.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/bellsoft-liberica
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
[INFO]     [creator]         $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
[INFO]     [creator]         $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
[INFO]     [creator]         $BP_JVM_VERSION              17                                                           the Java version
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
[INFO]     [creator]         $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
[INFO]     [creator]         $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
[INFO]     [creator]         $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
[INFO]     [creator]         $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
[INFO]     [creator]         $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
[INFO]     [creator]         $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
[INFO]     [creator]         $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
[INFO]     [creator]         $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
[INFO]     [creator]         $BPL_JMX_PORT                5000                                                         configure the JMX port
[INFO]     [creator]         $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
[INFO]     [creator]         $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
[INFO]     [creator]         $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
[INFO]     [creator]         $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
[INFO]     [creator]         Using Java version 21 extracted from MANIFEST.MF
[INFO]     [creator]       BellSoft Liberica NIK 21.0.2: Contributing to layer
[INFO]     [creator]         Downloading from https://github.com/bell-sw/LibericaNIK/releases/download/23.1.2+1-21.0.2+14/bellsoft-liberica-vm-core-openjdk21.0.2+14-23.1.2+1-linux-aarch64.tar.gz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]         Expanding to /layers/paketo-buildpacks_bellsoft-liberica/native-image-svm
[INFO]     [creator]         Adding 137 container CA certificates to JVM truststore
[INFO]     [creator]         Writing env.build/JAVA_HOME.override
[INFO]     [creator]         Writing env.build/JDK_HOME.override
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Syft 1.46.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/syft
[INFO]     [creator]         Downloading from https://github.com/anchore/syft/releases/download/v0.105.1/syft_0.105.1_linux_arm64.tar.gz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]         Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Executable JAR 6.9.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/executable-jar
[INFO]     [creator]       Command "packages" is deprecated, use `syft scan` instead
[INFO]     [creator]       Class Path: Contributing to layer
[INFO]     [creator]         Writing env/CLASSPATH.delim
[INFO]     [creator]         Writing env/CLASSPATH.prepend
[INFO]     [creator]       Process types:
[INFO]     [creator]         executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct)
[INFO]     [creator]         task:           java org.springframework.boot.loader.launch.JarLauncher (direct)
[INFO]     [creator]         web:            java org.springframework.boot.loader.launch.JarLauncher (direct)
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Spring Boot 5.28.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/spring-boot
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_SPRING_CLOUD_BINDINGS_DISABLED   false  whether to contribute Spring Boot cloud bindings support
[INFO]     [creator]         $BP_SPRING_CLOUD_BINDINGS_VERSION    1      default version of Spring Cloud Bindings library to contribute
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false  whether to auto-configure Spring Boot environment properties from bindings
[INFO]     [creator]         $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true   Deprecated - whether to auto-configure Spring Boot environment properties from bindings
[INFO]     [creator]       Class Path: Contributing to layer
[INFO]     [creator]         Writing env.build/CLASSPATH.append
[INFO]     [creator]         Writing env.build/CLASSPATH.delim
[INFO]     [creator]       Image labels:
[INFO]     [creator]         org.opencontainers.image.title
[INFO]     [creator]         org.opencontainers.image.version
[INFO]     [creator]         org.springframework.boot.version
[INFO]     [creator]     Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to <layer>.sbom.<ext>, launch.sbom.<ext>, or build.sbom.<ext>.
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Native Image 5.13.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/native-image
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_BINARY_COMPRESSION_METHOD                Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
[INFO]     [creator]         $BP_NATIVE_IMAGE                       true  enable native image build
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS             arguments to pass to the native-image command
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE        a file with arguments to pass to the native-image command
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILT_ARTIFACT              the built application artifact explicitly, required if building from a JAR
[INFO]     [creator]       Command "packages" is deprecated, use `syft scan` instead
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     error running version
[INFO]     [creator]     unable to start PTY
[INFO]     [creator]     fork/exec /layers/paketo-buildpacks_bellsoft-liberica/native-image-svm/bin/native-image: no such file or directory
[INFO]     [creator]     ERROR: failed to build: exit status 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants