From c4f4223371a9b65cfb964387abb3052d73596e6f Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 22 Feb 2022 06:37:08 +0200 Subject: [PATCH] Fix out of date information about JVM debugging with Jib Fixes: #23841 --- docs/src/main/asciidoc/container-image.adoc | 22 +++++++-------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/docs/src/main/asciidoc/container-image.adoc b/docs/src/main/asciidoc/container-image.adoc index 88a4179910470..faa860b46e789 100644 --- a/docs/src/main/asciidoc/container-image.adoc +++ b/docs/src/main/asciidoc/container-image.adoc @@ -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