Skip to content

Commit

Permalink
Merge pull request #23853 from geoand/#23841
Browse files Browse the repository at this point in the history
Fix out of date information about JVM debugging with Jib
  • Loading branch information
gsmet committed Feb 22, 2022
2 parents 27f7b3d + c4f4223 commit 11d28b8
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions docs/src/main/asciidoc/container-image.adoc
Expand Up @@ -43,28 +43,20 @@ For example, the presence of `src/main/jib/foo/bar` would result in `/foo/bar`
==== JVM Debugging

There are cases where the built container image may need to have Java debugging conditionally enabled at runtime.
There are a few ways to achieve this, but they all rely on the fact that in the `container-image-jib` you can control the entrypoint to use for the container image.
By default, the container-image is created with a minimal `java -jar ...` style entrypoint, but that can be changed using the `quarkus.jib.jvm-entrypoint` configuration option.

If the base image has not been changed (and therefore `fabric8/java-alpine-openjdk11-jre` is used) then you leverage that image's built-in `run-java.sh` script (more details about it can be found link:https://hub.docker.com/r/fabric8/java-alpine-openjdk11-jre#startup-script-run-javash[here]])
by adding the following entries to `application.properties`:
When the base image has not been changed (and therefore `ubi8/openjdk-11-runtime` or `ubi8/openjdk-17-runtime` is used), then the `quarkus.jib.jvm-arguments` configuration property can be used in order to
make the JVM listen on the debug port at startup.

The exact configuration is:

[source,properties]
----
quarkus.jib.jvm-entrypoint=/deployments/run-java.sh #this is the location of the script in the container image
quarkus.jib.environment-variables."JAVA_APP_DIR"=/work #this is needed so the script knows where the Quarkus jar is
quarkus.jib.jvm-arguments=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=n\\,address=*:5005
----

When running the container, the `JAVA_DEBUG` environment variable can then be used to control whether or not the application will be listening on the debug port.

An example launch command is:

[source,bash]
----
docker run --rm -p 8080:8080 -p 5005:5005 -e JAVA_DEBUG=true quarkus/getting-started:1.0.0-SNAPSHOT
----
Other base images might provide launch scripts that enable debugging when an environment variable is set, in which case you would set than environment variable when launching the container.

If you are using a different base image or would like to use a custom launch script, then see the previous section on how to add the script to the container image and set the `quarkus.jib.jvm-entrypoint` in `application.properties` to the location of that script.
Finally, the `quarkus.jib.jvm-entrypoint` configuration property can be used to completely override the container entry point and can thus be used to either hard code the JVM debug configuration or point to a script that handles the details.

[#docker]
=== Docker
Expand Down

0 comments on commit 11d28b8

Please sign in to comment.