Skip to content

Docker changes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:8-jre-alpine
LABEL description="java-mysql-example-app"
LABEL version="1.0"
LABEL maintainer="Hatem AlSum ([email protected])"

ADD target/java-mysql-example-app-1.0-SNAPSHOT-jar-with-dependencies.jar app.jar

CMD echo "The application will start now..." && \
sleep 60s && \
java -jar app.jar
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '2'
services:
java-app:
image: jexampleapp
environment:
- PORT=8080
- MYSQLS_HOSTNAME=app-mysql
- MYSQLS_PORT=3306
- MYSQLS_USERNAME=root
- MYSQLS_PASSWORD=my-secret-pw
- MYSQLS_DATABASE=mysql
ports:
- 8080:8080
depends_on:
- app-mysql
app-mysql :
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=my-secret-pw
ports:
- 3306:3306
53 changes: 40 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cloudcontrolled.sample.mysql</groupId>
<artifactId>java-mysql-example-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<groupId>com.cloudcontrolled.sample.mysql</groupId>
<artifactId>java-mysql-example-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>mysql</groupId>
Expand All @@ -16,7 +15,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.0.v20120127</version>
<version>9.3.8.v20160314</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand All @@ -40,7 +39,12 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -49,10 +53,33 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.cloudcontrolled.sample.mysql.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expand Down