Skip to content

Commit 754bbf3

Browse files
committed
initial commit
0 parents  commit 754bbf3

File tree

12 files changed

+86
-0
lines changed

12 files changed

+86
-0
lines changed

Diff for: .dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
*.swp

Diff for: Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM ehazlett/tomcat7
2+
COPY dbtest /opt/tomcat/webapps/dbtest
3+

Diff for: dbtest/META-INF/context.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Context>
2+
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
3+
maxActive="100" maxIdle="30" maxWait="10000"
4+
username="java" password="java" driverClassName="com.mysql.jdbc.Driver"
5+
url="jdbc:mysql://mysql:3306/javatest"/>
6+
</Context>
7+
8+

Diff for: dbtest/WEB-INF/lib/jstl.jar

20.2 KB
Binary file not shown.

Diff for: dbtest/WEB-INF/lib/mysql.jar

938 KB
Binary file not shown.

Diff for: dbtest/WEB-INF/lib/standard.jar

384 KB
Binary file not shown.

Diff for: dbtest/WEB-INF/web.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
4+
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
5+
version="2.4">
6+
<description>MySQL Test App</description>
7+
<resource-ref>
8+
<description>DB Connection</description>
9+
<res-ref-name>jdbc/TestDB</res-ref-name>
10+
<res-type>javax.sql.DataSource</res-type>
11+
<res-auth>Container</res-auth>
12+
</resource-ref>
13+
</web-app>

Diff for: dbtest/index.jsp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
2+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3+
4+
<sql:query var="rs" dataSource="jdbc/TestDB">
5+
select id, foo, bar from testdata
6+
</sql:query>
7+
8+
<html>
9+
<head>
10+
<title>DB Test</title>
11+
</head>
12+
<body>
13+
14+
<h2>Results</h2>
15+
16+
<c:forEach var="row" items="${rs.rows}">
17+
Foo ${row.foo}<br/>
18+
Bar ${row.bar}<br/>
19+
</c:forEach>
20+
21+
</body>
22+
</html>

Diff for: fig.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
db:
2+
image: orchardup/mysql
3+
environment:
4+
MYSQL_USER: java
5+
MYSQL_PASSWORD: java
6+
MYSQL_DATABASE: javatest
7+
ports:
8+
- "3306"
9+
10+
dbinit:
11+
image: orchardup/mysql
12+
entrypoint: /bin/bash
13+
volumes:
14+
- .:/host
15+
command: -c "sleep 4; mysql -u java --password=java -h mysql javatest < /host/init.sql; exit 0"
16+
links:
17+
- db:mysql
18+
19+
app:
20+
build: .
21+
links:
22+
- dbinit
23+
- db:mysql
24+
ports:
25+
- "8080"

Diff for: init.sql

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
create table testdata (id int not null auto_increment primary key,foo varchar(25),bar int);
2+
insert into testdata values(null, 'hello', 12345);

Diff for: readme.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Docker Java/MySQL Tomcat Sample
2+
This is a simple Java application that shows Java and MySQL.
3+
4+
# Run
5+
6+
`fig up -d`
7+
8+
Then run `fig ps` to find the app port.
9+
10+
You should be able to access the app on http://<docker-host-ip>:<app-port>/dbtest

0 commit comments

Comments
 (0)