Welcome to the DropWizard Demo Application !
The goal of this repository is to show a tiny application example to illustrate build pipelines and tools
To be built, this application needs:
- JDK 11 (OpenJDK is fine) as SDK
- Maven 3.3 as build tool
Clone the repository wherever Maven + JDK is available
- Maven 3.3 installation on "metal" with your JDK
- A Maven + JDK Docker image
- A Virtual Machine with Maven and JDK
From the root of the repository:
- Whole building process is as simple as
mvn clean install
- Just compiling classes:
mvn clean compile
- Running unit tests (implies compiling):
mvn test
- Running Integration tests (implies compiling but NO unit tests):
mvn verify
- Generating the standalone application:
mvn package
- "Installing" application in the local Maven repository:
mvn install
The awesome DropWizard framework makes the generated application a standalone one.
You can run it with just a Java JRE 8 installed:
java -jar ./target/demoapp.jar server ./hello-world.yml
The application will then be available on http://localhost:8080/ if everything went smoothly
They are a lot of reasons that would make you NOT wanting to launch application in Bare Metal:
- Developer Syndrom (portability concerns): "It works on my machine" (your JDK and Maven installation)
- Security concerns: "What is this application doing ?"
- Ease of run: If any application is already running on
the
8080
port of your machine, you'll be required to dig into the codebase + documentation to change listening ports.
This is why you can run the application with your own baked Docker image.
- A
Dockerfile
is provided at the root of the repository - First step is to "build" the Docker image:
docker build -t dw-demo-app:latest ./
- Then run it in background, letting Docker selecting a port:
CID=$(docker run -d -P dw-demo-app:latest)
- Fetch the allocated port by asking docker:
- Note that a simple
docker ps
could be sufficient, but not very machine-readable
- Note that a simple
docker port ${CID} 8080
Example: 0.0.0.0:37567
-
Browse to the application homepage, using the fetched port: http://{DOCKER SERVICE IP}:37567
- {DOCKER SERVICE IP} is the IP address of your Docker service:
localhost
on Docker4Mac or Docker4Windows- The result of
boot2docker ip
using Docker toolbox
- {DOCKER SERVICE IP} is the IP address of your Docker service:
-
Stop and clean the application:
docker stop ${CID} && docker rm -v ${CID}