Skip to content

Commit

Permalink
BAEL-1614 - Docker with Java Guest Post (eugenp#4474)
Browse files Browse the repository at this point in the history
* BAEL-1614 - additions for docker

* BAEL-1614 - move docker project to guest module
  • Loading branch information
egoebelbecker authored and maibin committed Jun 13, 2018
1 parent b59da11 commit 272f018
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
1 change: 0 additions & 1 deletion guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Manifest-Version: 1.0
Class-Path:

16 changes: 16 additions & 0 deletions guest/spring-boot-app/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Alpine Linux with OpenJDK JRE
FROM openjdk:8-jre-alpine
RUN apk add --no-cache bash

# copy fat WAR
COPY spring-boot-app-0.0.1-SNAPSHOT.war /app.war

# copy fat WAR
COPY logback.xml /logback.xml

COPY run.sh /run.sh

# runs application
#CMD ["/usr/bin/java", "-jar", "-Dspring.profiles.active=default", "-Dlogging.config=/logback.xml", "/app.war"]

ENTRYPOINT ["/run.sh"]
15 changes: 15 additions & 0 deletions guest/spring-boot-app/docker/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/var/log/Application/application.log</file>
<append>true</append>
<encoder>
<pattern>%-7d{yyyy-MM-dd HH:mm:ss:SSS} %m%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>
4 changes: 4 additions & 0 deletions guest/spring-boot-app/docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

java -Dspring.profiles.active=$1 -Dlogging.config=/logback.xml -jar /app.war

18 changes: 17 additions & 1 deletion guest/spring-boot-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,27 @@
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>com.stackify.Application</mainClass>
<outputDirectory>${project.basedir}/docker</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

<properties>
<tomcat.version>8.0.43</tomcat.version>
</properties>

</project>
</project>
1 change: 0 additions & 1 deletion spring-boot-ops/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
</goals>
<configuration>
<mainClass>com.baeldung.webjar.WebjarsdemoApplication</mainClass>
<outputDirectory>${project.basedir}/docker</outputDirectory>
</configuration>
</execution>
</executions>
Expand Down

0 comments on commit 272f018

Please sign in to comment.