#the artifact-id, group-id and version all those have no effect on the the artifacts, just the name #so the based on the name of the app you use it in the browser if the app in pom.xml "java-app-1.0" and in /var/lib//webapps/ is ghanem.war, to access the app u must write : localhost:8080/ghanem , if u want to use the root path remove the ROOT.war and just change the ghanem.war to ROOT.war
to Build war with maven and java-app framework
Steps are the following:
-
Clone the repository to your local machine
-
The Dockerfile will do:
A. Create maven container <br />
- copy pom.xml to /tmp
- copy folder "src" to /tmp/src
- Go to /tmp folder then run "mvn package"
The previos command will generate java-app.war
B. Create tomcat container<br />
- Will move the file java-app from maven container to /webapp in tomcat contaner
- Do health check to make sure that the artifact is deployed
- copy pom.xml to /tmp
-
Run 'docker build -t java-app .'
- Will create a Docker image called java
- Will create a Docker image called java
-
Run 'docker run -d -p 8080:8080 --name java-app java-app'
- Will create a container called java-app and will forward the container internal port 8080 to locathost 8080 in the hosted machine
-
Open [http://localhost:8080/ (http://localhost:8080/ in your browser and see the result.
Note : if you will use ansible you could do the following command (Run command as user Ansible )