Skip to content

Commit 272f018

Browse files
egoebelbeckermaibin
authored andcommitted
BAEL-1614 - Docker with Java Guest Post (eugenp#4474)
* BAEL-1614 - additions for docker * BAEL-1614 - move docker project to guest module
1 parent b59da11 commit 272f018

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Manifest-Version: 1.0
22
Class-Path:
3-
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Alpine Linux with OpenJDK JRE
2+
FROM openjdk:8-jre-alpine
3+
RUN apk add --no-cache bash
4+
5+
# copy fat WAR
6+
COPY spring-boot-app-0.0.1-SNAPSHOT.war /app.war
7+
8+
# copy fat WAR
9+
COPY logback.xml /logback.xml
10+
11+
COPY run.sh /run.sh
12+
13+
# runs application
14+
#CMD ["/usr/bin/java", "-jar", "-Dspring.profiles.active=default", "-Dlogging.config=/logback.xml", "/app.war"]
15+
16+
ENTRYPOINT ["/run.sh"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<include resource="org/springframework/boot/logging/logback/base.xml"/>
4+
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
5+
<file>/var/log/Application/application.log</file>
6+
<append>true</append>
7+
<encoder>
8+
<pattern>%-7d{yyyy-MM-dd HH:mm:ss:SSS} %m%n</pattern>
9+
</encoder>
10+
</appender>
11+
12+
<root level="INFO">
13+
<appender-ref ref="FILE" />
14+
</root>
15+
</configuration>

guest/spring-boot-app/docker/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
java -Dspring.profiles.active=$1 -Dlogging.config=/logback.xml -jar /app.war
4+

guest/spring-boot-app/pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,27 @@
5151
<warSourceDirectory>WebContent</warSourceDirectory>
5252
</configuration>
5353
</plugin>
54+
<plugin>
55+
<groupId>org.springframework.boot</groupId>
56+
<artifactId>spring-boot-maven-plugin</artifactId>
57+
<executions>
58+
<execution>
59+
<goals>
60+
<goal>repackage</goal>
61+
</goals>
62+
<configuration>
63+
<mainClass>com.stackify.Application</mainClass>
64+
<outputDirectory>${project.basedir}/docker</outputDirectory>
65+
</configuration>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
5470
</plugins>
5571
</build>
5672

5773
<properties>
5874
<tomcat.version>8.0.43</tomcat.version>
5975
</properties>
6076

61-
</project>
77+
</project>

spring-boot-ops/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138
</goals>
139139
<configuration>
140140
<mainClass>com.baeldung.webjar.WebjarsdemoApplication</mainClass>
141-
<outputDirectory>${project.basedir}/docker</outputDirectory>
142141
</configuration>
143142
</execution>
144143
</executions>

0 commit comments

Comments
 (0)