GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.5k stars 1.42k forks source link

Issue setting up profiler with Maven Jib #3951

Open thakurmiti opened 1 year ago

thakurmiti commented 1 year ago

Hello Team, I'm currently using maven jib in my current project and it's working fine. But now I wanted to implement a profiler to tackle heap memory-related issues. As to the setup profiler, we need to make sure the profiler agent is there in the container image and we just need to add the agent path between the jar command. e.g. -agentpath:INSTALL_DIR/profiler_java_agent.so=OPTION1,OPTION2,OPTION3.

https://cloud.google.com/profiler/docs/profiling-java#gke

As we are using jib maven, I'm adding the profiler agent in the base jib image but I'm not able to locate the jar file that jib used to create after building the project. I tried adding the agent command via entrypoint and args section but it's not working. I'm unable to find any info related to how jib creates the jar file and how we can add any arguments with it.

It will be really helpful if you can help with this.

thakurmiti commented 1 year ago

Update I could see that jib maven add entrypoint as [java, -cp, @/app/jib-classpath-file, javafilename]. But it's still not working if I add agent path in it, in pom file.

jingwenyang2023 commented 1 year ago

same problem here, would love to see the progress!

jingwenyang2023 commented 1 year ago

same problem here, would love to see the progress! the docker image built successfully but when launching container it fails with the following errors...

image

chanseokoh commented 1 year ago

Here is an example in both Maven and Gradle that loads a Java agent. It makes Gradle and Maven dynamically download an agent during project building, but embedding it in the base image also works.

https://github.com/GoogleContainerTools/jib/tree/master/examples/java-agent