Hot-deploying Java Enterprise with WAD & Docker
I’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:
01 02 03 04 05 06 07 08 09 10 11 12 | #!/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:
1 2 3 4 | ... [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:
Success! Now check your email to confirm your subscription.
© Sebastian Daschner, CC BY-NC-SA 4.0
Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: Hot-deploying Java Enterprise with WAD & Docker (Video) Opinions expressed by Java Code Geeks contributors are their own. |