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

Fix out of date information about JVM debugging with Jib #23853

Merged
merged 1 commit into from Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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