In an earlier video, I shared how to run the Quarkus
remote-dev mode in Docker containers, which is very helpful for local and remote development environments. Since Quarkus version
1.6, however, the way how we execute the remote dev mode has changed.
Assuming, we’d like to have the same setup like in the mentioned video.
What’s new is that we don’t have to start the remote Quarkus instance with Maven, but instead use a different packaging mode and some System variables.
You can check out the documentation how these different package modes are specified.
I want to continue running my production application in the same way as before, and only the remote-dev-enabled mode will be built differently:
# for remote-dev-mode mvn clean package -Dquarkus.package.type=mutable-jar docker build -f Dockerfile.dev -t tmp-builder . docker run --rm \ --name coffee-shop \ -p 8080:8080 \ -p 5005:5005 \ tmp-builder
Our Quarkus app will be packaged as
mutable-jar application and bundled in a Docker image. Our local Docker container will be started with published HTTP port
8080 and debug port
Dockerfile.dev file looks now as follows:
# Dockerfile for remote-dev-mode 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"]
The application will be started in (remote) dev mode, once the
QUARKUS_LAUNCH_DEVMODE environment variable is set to
true. Additionally, we define
JAVA_ENABLE_DEBUG to get the same result like previously, namely that we can remote-debug our application via port
Then, from a new terminal we start the Maven
mvn quarkus:remote-dev -Ddebug=false \ -Dquarkus.package.type=mutable-jar \ -Dquarkus.live-reload.url=http://localhost:8080 \ -Dquarkus.live-reload.password=123
The local Maven instance should not listen to a debug port, and we provide the same connection and packaging information.
Now, we can connect to
localhost:8080, debug via
localhost:5005, and see our source code changes being reflected in the running Quarkus application, again.
Opinions expressed by Java Code Geeks contributors are their own.