sebastiandaschner blog
Hot-deploying Java Enterprise with WAD & Docker (Video)
wednesday, march 27, 2019I’ve recorded a video how to minimize the development turnaround times with Watch and Deploy (WAD) by Adam Bien and Docker containers. The WAD tool watches for file changes and will re-build and re-deploy our applications to an auto-deployment directory. We’ll see how that approach can be integrated into containers that are created by the same Docker images that run in production.
Besides the news around the fast turnaround with Quarkus, which is a very interesting project, it’s possible to have a good development experience solely with Java EE and application servers that deploy quickly. The WAD tool watches for any changes that we make in the project and re-deploys our applications. If you run your application in Docker containers you can and in fact should use the same Docker image locally that you will later run in production.
For our purposes, we’ll mount the auto-deployment directory into the local Docker container. WAD will watch our project directory and hot-update the deployment artifact accordingly.
You could automate the Docker images creation, container start, and WAD invocation similar to the following:
#!/bin/bash
docker build -t test-project:1 .
docker stop test-project || true
docker run -d --rm \
--name test-project \
-p 9080:9080 \
-v /tmp/wad-dropins/:/opt/wlp/usr/servers/defaultServer/dropins/ \
test-project:1
java -jar <path-to-wad>/wad.jar /tmp/wad-dropins/
If you then change code files in your application, WAD will re-build your application, copy the artifact to the directory, which is mapped into the container, and your application server re-deploys the app.
In my video, I use Open Liberty which fast enough for my purposes:
...
[AUDIT]: The application test-project has stopped successfully.
[AUDIT]: Web application available (default_host) http://44ae8449d5eb:9080/test-project/
[AUDIT]: The application test-project updated in 0.685 seconds.
Happy productive development!
Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: