Skip to content

contagiouscoder777/demo-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo Java Web App

Simple java project demos how to build a war file to be deployed on a Tomcat server.

Build

The build script uses mvn package to produce a demo.war file and then bundles it with a Docker image that runs Tomcat. Usage:

bin/build

What happened

  • mvn package was ran and the target/demo.war was moved into pkg/demo.war
  • a docker image was built which copied the pkg/demo.war to /usr/local/tomcat/webapps/demo.war. Check out the Dockerfile for details.

Here's an example of some things to check after running the build script:

$ ls pkg/demo.war
pkg/demo.war
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
demo-java           latest              88092dfb7325        6 minutes ago       591MB
tomcat              8.5                 a92c139758db        2 weeks ago         558MB
$

Run

To run and test that Tomcat is serving the the war file:

docker run --rm -p 8080:8080 demo-java

Then you can hit the the [HOSTNAME]:8080/demo/Hello and to verify that Tomcat is servering the demo.war file. You should see an html page that says "Hello World"

Usage with UFO

The ufo branch of this project provides an additional demo that takes the war artifact, builds a Docker image and deploys it to ECS. For details please check out that branch: ufo. For more details on ufo check out the official ufo docs.

Initial Generation

Here are some notes on the initial generation of the project. The initial files and project structure was generated with the mvn archetype:generate command. Note, you do not have to run the command it is just noted here for posterity. More info: Creating a webapp and Introduction to the Standard Directory Layout.

Change were made like adding a simple Hello.java Serlvet class.

The original command was:

mvn archetype:generate \
  -DinteractiveMode=false \
  -DgroupId=com.domain \
  -DartifactId=demo \
  -DarchetypeArtifactId=maven-archetype-webapp

Dependencies

  • docker: brew install docker
  • maven: brew install maven

About

simple demo app that shows how to build a java war and a Docker image that uses Tomcat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 45.4%
  • Dockerfile 31.6%
  • Shell 23.0%