Skip to content

Commit 95e3b9d

Browse files
committed
Docker changes
1 parent 42f1a5c commit 95e3b9d

File tree

3 files changed

+71
-13
lines changed

3 files changed

+71
-13
lines changed

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM openjdk:8-jre-alpine
2+
LABEL description="java-mysql-example-app"
3+
LABEL version="1.0"
4+
LABEL maintainer="Hatem AlSum ([email protected])"
5+
6+
ADD target/java-mysql-example-app-1.0-SNAPSHOT-jar-with-dependencies.jar app.jar
7+
8+
CMD echo "The application will start now..." && \
9+
sleep 60s && \
10+
java -jar app.jar

docker-compose.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '2'
2+
services:
3+
java-app:
4+
image: jexampleapp
5+
environment:
6+
- PORT=8080
7+
- MYSQLS_HOSTNAME=app-mysql
8+
- MYSQLS_PORT=3306
9+
- MYSQLS_USERNAME=root
10+
- MYSQLS_PASSWORD=my-secret-pw
11+
- MYSQLS_DATABASE=mysql
12+
ports:
13+
- 8080:8080
14+
depends_on:
15+
- app-mysql
16+
app-mysql :
17+
image: mysql:5.7
18+
environment:
19+
- MYSQL_ROOT_PASSWORD=my-secret-pw
20+
ports:
21+
- 3306:3306

pom.xml

+40-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
43
http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
6-
<groupId>com.cloudcontrolled.sample.mysql</groupId>
7-
<artifactId>java-mysql-example-app</artifactId>
8-
<version>1.0-SNAPSHOT</version>
9-
<packaging>jar</packaging>
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.cloudcontrolled.sample.mysql</groupId>
6+
<artifactId>java-mysql-example-app</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
109
<dependencies>
1110
<dependency>
1211
<groupId>mysql</groupId>
@@ -16,7 +15,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
1615
<dependency>
1716
<groupId>org.eclipse.jetty</groupId>
1817
<artifactId>jetty-servlet</artifactId>
19-
<version>7.6.0.v20120127</version>
18+
<version>9.3.8.v20160314</version>
2019
</dependency>
2120
<dependency>
2221
<groupId>javax.servlet</groupId>
@@ -40,7 +39,12 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
4039
<execution>
4140
<id>copy-dependencies</id>
4241
<phase>package</phase>
43-
<goals><goal>copy-dependencies</goal></goals>
42+
<goals>
43+
<goal>copy-dependencies</goal>
44+
</goals>
45+
<configuration>
46+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
47+
</configuration>
4448
</execution>
4549
</executions>
4650
</plugin>
@@ -49,10 +53,33 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
4953
<artifactId>maven-compiler-plugin</artifactId>
5054
<version>2.3.2</version>
5155
<configuration>
52-
<source>1.6</source>
53-
<target>1.6</target>
56+
<source>1.8</source>
57+
<target>1.8</target>
5458
</configuration>
55-
</plugin>
59+
</plugin>
60+
<plugin>
61+
<artifactId>maven-assembly-plugin</artifactId>
62+
<executions>
63+
<execution>
64+
<phase>package</phase>
65+
<goals>
66+
<goal>single</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
<configuration>
71+
<archive>
72+
<manifest>
73+
<addClasspath>true</addClasspath>
74+
<classpathPrefix>lib/</classpathPrefix>
75+
<mainClass>com.cloudcontrolled.sample.mysql.App</mainClass>
76+
</manifest>
77+
</archive>
78+
<descriptorRefs>
79+
<descriptorRef>jar-with-dependencies</descriptorRef>
80+
</descriptorRefs>
81+
</configuration>
82+
</plugin>
5683
</plugins>
5784
</build>
5885
</project>

0 commit comments

Comments
 (0)