Skip to content

Instantly share code, notes, and snippets.

@philipz
Last active January 10, 2021 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipz/734b7e7595a8a3702f937a30ad5c5d81 to your computer and use it in GitHub Desktop.
Save philipz/734b7e7595a8a3702f937a30ad5c5d81 to your computer and use it in GitHub Desktop.
Quarkus Remote debug with Kubernetes

Ref: Quarkus remote dev in Docker containers (Update)

mvn quarkus:add-extension -Dextensions=quarkus-kubernetes
Add `quarkus.kubernetes.service-type=load-balancer` in application.properties
mvn clean package -Dquarkus.package.type=mutable-jar
docker build -f src/main/docker/Dockerfile.dev -t philipz/micrometer-quickstart:1.0.0-SNAPSHOT .
docker push philipz/micrometer-quickstart:1.0.0-SNAPSHOT
kubectl apply -f target/kubernetes/kubernetes.yml
mvn quarkus:remote-dev -Ddebug=false \
  -Dquarkus.package.type=mutable-jar \
  -Dquarkus.live-reload.url=http://localhost:31469 \
  -Dquarkus.live-reload.password=123
FROM adoptopenjdk/openjdk14-openj9:x86_64-alpine-jre-14_36.1_openj9-0.19.0
RUN apk add curl
ENV QUARKUS_LAUNCH_DEVMODE=true \
JAVA_ENABLE_DEBUG=true
COPY target/quarkus-app/lib/ /deployments/lib/
COPY target/quarkus-app/*.jar /deployments/
COPY target/quarkus-app/app/ /deployments/app/
COPY target/quarkus-app/quarkus/ /deployments/quarkus/
CMD ["java", "-jar", \
"-Dquarkus.http.host=0.0.0.0", \
"-Djava.util.logging.manager=org.jboss.logmanager.LogManager", \
"-Dquarkus.package.type=mutable-jar", \
"-Dquarkus.live-reload.password=123", \
"/deployments/quarkus-run.jar"]
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the container image run:
#
# ./mvnw package -Dquarkus.package.type=fast-jar
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.fast-jar -t quarkus/micrometer-quickstart-fast-jar .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/micrometer-quickstart-fast-jar
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/micrometer-quickstart-fast-jar
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus.package.type=mutable-jar -Dquarkus.live-reload.password=123"
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "quarkus:dev",
"type": "java",
"request": "attach",
"hostName": "localhost",
"name": "Debug Quarkus application",
"port": 5005
},
{
"preLaunchTask": "quarkus:remote-dev",
"type": "java",
"request": "attach",
"hostName": "localhost",
"name": "Remote Debug Quarkus application",
"port": 5005
}
]
}
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"label": "quarkus:dev",
"type": "shell",
"command": "./mvnw quarkus:dev",
"windows": {
"command": ".\\mvnw.cmd quarkus:dev"
},
"isBackground": true,
"problemMatcher": [
{
"pattern": [
{
"regexp": "\\b\\B",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^.*Scanning for projects...*",
"endsPattern": "^.*Quarkus .* started in .*\\. Listening on:*"
}
}
]
},
{
"label": "quarkus:remote-dev",
"type": "shell",
"command": "./mvnw quarkus:remote-dev -Ddebug=false -Dquarkus.package.type=mutable-jar -Dquarkus.live-reload.url=http://localhost:8080 -Dquarkus.live-reload.password=123",
"windows": {
"command": ".\\mvnw.cmd quarkus:dev -Ddebug=false -Dquarkus.package.type=mutable-jar -Dquarkus.live-reload.url=http://localhost:8080 -Dquarkus.live-reload.password=123"
},
"isBackground": true,
"problemMatcher": [
{
"pattern": [
{
"regexp": "\\b\\B",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^.*Scanning for projects...*",
"endsPattern": "^.*Quarkus augmentation completed in *"
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment