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

Buildpacks Gradle integration #2492

Closed
manusa opened this issue Dec 4, 2023 · 3 comments
Closed

Buildpacks Gradle integration #2492

manusa opened this issue Dec 4, 2023 · 3 comments
Assignees
Milestone

Comments

@manusa
Copy link
Member

manusa commented Dec 4, 2023

Description

Part of #439

As a user, I want to be able to use JKube's buildpacks functionality from Gradle, so that I can easily integrate buildpacks in my Gradle project.

@rohanKanojia
Copy link
Member

We have added BuildPackBuildService in jkube-kit/config/service module.

This module is already added as a dependency in kubernetes-gradle-plugin

https://github.com/eclipse/jkube/blob/d828cd269470d354e752351a0539e98c7c02f31e/gradle-plugin/kubernetes/pom.xml#L40-L44

@rohanKanojia
Copy link
Member

I tested on a simple Spring Boot Project and I was able to test k8sBuild with BuildPacks Build strategy:

gradle-it : $ gradle k8sBuild -Pjkube.buildpacks.strategy=buildpacks
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.5/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build 

> Task :k8sBuild
k8s: Running generator spring-boot
k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java:0.0.23 as base / builder
k8s: Spring Boot layered jar detected
k8s: Building container image in Kubernetes mode
k8s: Delegating container image building process to BuildPacks
k8s: Using pack /home/rokumar/.jkube/pack
k8s: base: Pulling from paketobuildpacks/builder
k8s: Digest: sha256:17ea21162ba8c7717d3ead3ee3836a368aced7f02f2e59658e52029bd6d149e7
k8s: Status: Image is up to date for paketobuildpacks/builder:base
k8s: base-cnb: Pulling from paketobuildpacks/run
k8s: Digest: sha256:1af9935d8987fd52b2266d288200c9482d1dd5529860bbf5bc2d248de1cb1a38
k8s: Status: Image is up to date for paketobuildpacks/run:base-cnb
k8s: 0.16.5: Pulling from buildpacksio/lifecycle
k8s: Digest: sha256:6328c7b662c452111e39f1f5d5d097292d07c218ba4a873f0ad0c2cb67710869
k8s: Status: Image is up to date for buildpacksio/lifecycle:0.16.5
k8s: ===> ANALYZING
k8s: [analyzer] Restoring data for SBOM from previous image
k8s: ===> DETECTING
k8s: [detector] 10 of 26 buildpacks participating
k8s: [detector] paketo-buildpacks/ca-certificates   3.6.3
k8s: [detector] paketo-buildpacks/bellsoft-liberica 10.2.6
k8s: [detector] paketo-buildpacks/syft              1.32.1
k8s: [detector] paketo-buildpacks/gradle            7.3.0
k8s: [detector] paketo-buildpacks/executable-jar    6.7.4
k8s: [detector] paketo-buildpacks/apache-tomcat     7.13.7
k8s: [detector] paketo-buildpacks/apache-tomee      1.7.4
k8s: [detector] paketo-buildpacks/liberty           3.8.2
k8s: [detector] paketo-buildpacks/dist-zip          5.6.4
k8s: [detector] paketo-buildpacks/spring-boot       5.26.1
k8s: ===> RESTORING
k8s: [restorer] Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
k8s: [restorer] Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jre" from app image
k8s: [restorer] Restoring metadata for "paketo-buildpacks/bellsoft-liberica:helper" from app image
k8s: [restorer] Restoring metadata for "paketo-buildpacks/bellsoft-liberica:java-security-properties" from app image
k8s: [restorer] Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jdk" from cache
k8s: [restorer] Restoring metadata for "paketo-buildpacks/syft:syft" from cache
k8s: [restorer] Restoring metadata for "paketo-buildpacks/gradle:application" from cache
k8s: [restorer] Restoring metadata for "paketo-buildpacks/gradle:cache" from cache
k8s: [restorer] Restoring data for "paketo-buildpacks/bellsoft-liberica:jdk" from cache
k8s: [restorer] Restoring data for "paketo-buildpacks/syft:syft" from cache
k8s: [restorer] Restoring data for "paketo-buildpacks/gradle:application" from cache
k8s: [restorer] Restoring data for "paketo-buildpacks/gradle:cache" from cache
k8s: [restorer] Restoring data for SBOM from cache
k8s: ===> BUILDING
k8s: [builder] 
k8s: [builder] Paketo Buildpack for CA Certificates 3.6.3
k8s: [builder]   https://github.com/paketo-buildpacks/ca-certificates
k8s: [builder]   Launch Helper: Reusing cached layer
k8s: [builder] 
k8s: [builder] Paketo Buildpack for BellSoft Liberica 10.2.6
k8s: [builder]   https://github.com/paketo-buildpacks/bellsoft-liberica
k8s: [builder]   Build Configuration:
k8s: [builder]     $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
k8s: [builder]     $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
k8s: [builder]     $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
k8s: [builder]     $BP_JVM_VERSION              17                                                           the Java version
k8s: [builder]   Launch Configuration:
k8s: [builder]     $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
k8s: [builder]     $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
k8s: [builder]     $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
k8s: [builder]     $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
k8s: [builder]     $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
k8s: [builder]     $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
k8s: [builder]     $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
k8s: [builder]     $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
k8s: [builder]     $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
k8s: [builder]     $BPL_JMX_PORT                5000                                                         configure the JMX port
k8s: [builder]     $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
k8s: [builder]     $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
k8s: [builder]     $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
k8s: [builder]     $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
k8s: [builder]     Using buildpack default Java version 17
k8s: [builder]   BellSoft Liberica JDK 17.0.7: Reusing cached layer
k8s: [builder]   BellSoft Liberica JRE 17.0.7: Reusing cached layer
k8s: [builder]   Launch Helper: Reusing cached layer
k8s: [builder]   Java Security Properties: Reusing cached layer
k8s: [builder] 
k8s: [builder] Paketo Buildpack for Syft 1.32.1
k8s: [builder]   https://github.com/paketo-buildpacks/syft
k8s: [builder]     Downloading from https://github.com/anchore/syft/releases/download/v0.84.0/syft_0.84.0_linux_amd64.tar.gz
k8s: [builder]     Verifying checksum
k8s: [builder]     Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
k8s: [builder] 
k8s: [builder] Paketo Buildpack for Gradle 7.3.0
k8s: [builder]   https://github.com/paketo-buildpacks/gradle
k8s: [builder]   Build Configuration:
k8s: [builder]     $BP_EXCLUDE_FILES                                                                       colon separated list of glob patterns, matched source files are removed
k8s: [builder]     $BP_GRADLE_ADDITIONAL_BUILD_ARGUMENTS                                                   the additionnal arguments (appended to BP_GRADLE_BUILD_ARGUMENTS) to pass to Gradle
k8s: [builder]     $BP_GRADLE_BUILD_ARGUMENTS             --no-daemon -Dorg.gradle.welcome=never assemble  the arguments to pass to Gradle
k8s: [builder]     $BP_GRADLE_BUILD_FILE                                                                   the location of the main build config file, relative to the application root
k8s: [builder]     $BP_GRADLE_BUILT_ARTIFACT              build/libs/*.[jw]ar                              the built application artifact explicitly.  Supersedes $BP_GRADLE_BUILT_MODULE
k8s: [builder]     $BP_GRADLE_BUILT_MODULE                                                                 the module to find application artifact in
k8s: [builder]     $BP_GRADLE_INIT_SCRIPT_PATH                                                             the path to a Gradle init script file
k8s: [builder]     $BP_INCLUDE_FILES                                                                       colon separated list of glob patterns, matched source files are included
k8s: [builder]     $BP_JAVA_INSTALL_NODE                  false                                            whether to install Yarn/Node binaries based on the presence of a package.json or yarn.lock file
k8s: [builder]     $BP_NODE_PROJECT_PATH                                                                   configure a project subdirectory to look for `package.json` and `yarn.lock` files
k8s: [builder]     Creating cache directory /home/cnb/.gradle
k8s: [builder]   Compiled Application: Contributing to layer
k8s: [builder]     Executing gradlew --no-daemon -Dorg.gradle.welcome=never assemble
k8s: [builder]       To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.2.1/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
k8s: [builder]       Daemon will be stopped at the end of the build 
k8s: [builder]       > Task :compileJava
k8s: [builder]       > Task :processResources
k8s: [builder]       > Task :classes
k8s: [builder]       > Task :resolveMainClassName
k8s: [builder]       > Task :bootJar
k8s: [builder]       > Task :jar
k8s: [builder]       > Task :assemble
k8s: [builder]       
k8s: [builder]       BUILD SUCCESSFUL in 8s
k8s: [builder]       5 actionable tasks: 5 executed
k8s: [builder] 
k8s: [builder]   Removing source code
k8s: [builder]   Restoring multiple artifacts
k8s: [builder] 
k8s: [builder] Paketo Buildpack for Executable JAR 6.7.4
k8s: [builder]   https://github.com/paketo-buildpacks/executable-jar
k8s: [builder]   Process types:2s]
k8s: [builder]     executable-jar: java -jar /workspace/jkube-buildpacks-buildstrategy-poc-demo-0.0.1-SNAPSHOT.jar (direct)
k8s: [builder]     task:           java -jar /workspace/jkube-buildpacks-buildstrategy-poc-demo-0.0.1-SNAPSHOT.jar (direct)
k8s: [builder]     web:            java -jar /workspace/jkube-buildpacks-buildstrategy-poc-demo-0.0.1-SNAPSHOT.jar (direct)
k8s: ===> EXPORTING
k8s: [exporter] Reusing layer 'paketo-buildpacks/ca-certificates:helper'
k8s: [exporter] Reusing layer 'paketo-buildpacks/bellsoft-liberica:helper'
k8s: [exporter] Reusing layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
k8s: [exporter] Reusing layer 'paketo-buildpacks/bellsoft-liberica:jre'
k8s: [exporter] Adding layer 'buildpacksio/lifecycle:launch.sbom'
k8s: [exporter] Adding 1/1 app layer(s)
k8s: [exporter] Reusing layer 'buildpacksio/lifecycle:launcher'
k8s: [exporter] Reusing layer 'buildpacksio/lifecycle:config'
k8s: [exporter] Reusing layer 'buildpacksio/lifecycle:process-types'
k8s: [exporter] Adding label 'io.buildpacks.lifecycle.metadata'
k8s: [exporter] Adding label 'io.buildpacks.build.metadata'
k8s: [exporter] Adding label 'io.buildpacks.project.metadata'
k8s: [exporter] Setting default process type 'web'
k8s: [exporter] Saving user/jkube-buildpacks-buildstrategy-poc-demo:latest...
k8s: [exporter] *** Images (ba2bdda8162a):
k8s: [exporter]       user/jkube-buildpacks-buildstrategy-poc-demo:latest
k8s: [exporter] Reusing cache layer 'paketo-buildpacks/bellsoft-liberica:jdk'
k8s: [exporter] Reusing cache layer 'paketo-buildpacks/syft:syft'
k8s: [exporter] Adding cache layer 'paketo-buildpacks/gradle:application'
k8s: [exporter] Adding cache layer 'paketo-buildpacks/gradle:cache'
k8s: [exporter] Reusing cache layer 'buildpacksio/lifecycle:cache.sbom'
k8s: Successfully built image 'user/jkube-buildpacks-buildstrategy-poc-demo:latest'

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 39s
1 actionable task: 1 executed

@rohanKanojia rohanKanojia moved this from Planned to In Progress in Eclipse JKube Feb 6, 2024
@rohanKanojia rohanKanojia moved this from In Progress to Review in Eclipse JKube Feb 6, 2024
@manusa manusa added this to the 1.16.0 milestone Feb 7, 2024
@manusa
Copy link
Member Author

manusa commented Feb 7, 2024

Closing as complete

@manusa manusa closed this as completed Feb 7, 2024
@github-project-automation github-project-automation bot moved this from Review to Done in Eclipse JKube Feb 7, 2024
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

No branches or pull requests

2 participants