Skip to content

Commit 4572d89

Browse files
committed
Inital commit
0 parents  commit 4572d89

7 files changed

Lines changed: 49 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Dockerised Java application
2+
3+
The code for the blog post [http://geekyplatypus.com/packaging-and-serving-your-java-application-with-docker/](http://geekyplatypus.com/packaging-and-serving-your-java-application-with-docker/)
4+
5+
To start the application you need to have [Docker](https://www.docker.com/) installed and execute `./run.sh` in your shell.

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '2'
2+
services:
3+
web:
4+
image: tomcat
5+
ports:
6+
- "8080:8080"
7+
volumes:
8+
- ./target/DockerExample.war:/usr/local/tomcat/webapps/ROOT.war
9+
- ./target/DockerExample:/usr/local/tomcat/webapps/ROOT

pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mikechernev.docker.example</groupId>
5+
<artifactId>DockerExample</artifactId>
6+
<packaging>war</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>DockerExample Maven Webapp</name>
9+
<url>http://maven.apache.org</url>
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>3.8.1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
</dependencies>
18+
<build>
19+
<finalName>DockerExample</finalName>
20+
</build>
21+
</project>

run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run --rm -it -v /Users/mchernev/projects/posts/java-docker/DockerExample:/project -w /project maven mvn package && docker-compose up

src/main/webapp/WEB-INF/web.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE web-app PUBLIC
2+
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
3+
"http://java.sun.com/dtd/web-app_2_3.dtd" >
4+
5+
<web-app>
6+
<display-name>Archetype Created Web Application</display-name>
7+
</web-app>

src/main/webapp/index.jsp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
<h2>Hello World!</h2>
4+
</body>
5+
</html>

0 commit comments

Comments
 (0)