From 272f018f90673a5d7e86a7742aadb8a58d4cd33e Mon Sep 17 00:00:00 2001 From: Eric Goebelbecker Date: Wed, 13 Jun 2018 11:15:57 -0400 Subject: [PATCH] BAEL-1614 - Docker with Java Guest Post (#4474) * BAEL-1614 - additions for docker * BAEL-1614 - move docker project to guest module --- .../WebContent/META-INF/MANIFEST.MF | 1 - guest/spring-boot-app/docker/Dockerfile | 16 ++++++++++++++++ guest/spring-boot-app/docker/logback.xml | 15 +++++++++++++++ guest/spring-boot-app/docker/run.sh | 4 ++++ guest/spring-boot-app/pom.xml | 18 +++++++++++++++++- spring-boot-ops/pom.xml | 1 - 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 guest/spring-boot-app/docker/Dockerfile create mode 100644 guest/spring-boot-app/docker/logback.xml create mode 100755 guest/spring-boot-app/docker/run.sh diff --git a/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF b/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF index 254272e1c0..e3c07ab38a 100644 --- a/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF +++ b/guest/spring-boot-app/WebContent/META-INF/MANIFEST.MF @@ -1,3 +1,2 @@ Manifest-Version: 1.0 Class-Path: - diff --git a/guest/spring-boot-app/docker/Dockerfile b/guest/spring-boot-app/docker/Dockerfile new file mode 100644 index 0000000000..211e8927a3 --- /dev/null +++ b/guest/spring-boot-app/docker/Dockerfile @@ -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"] diff --git a/guest/spring-boot-app/docker/logback.xml b/guest/spring-boot-app/docker/logback.xml new file mode 100644 index 0000000000..7e03ddc827 --- /dev/null +++ b/guest/spring-boot-app/docker/logback.xml @@ -0,0 +1,15 @@ + + + + + /var/log/Application/application.log + true + + %-7d{yyyy-MM-dd HH:mm:ss:SSS} %m%n + + + + + + + diff --git a/guest/spring-boot-app/docker/run.sh b/guest/spring-boot-app/docker/run.sh new file mode 100755 index 0000000000..aeecc29371 --- /dev/null +++ b/guest/spring-boot-app/docker/run.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +java -Dspring.profiles.active=$1 -Dlogging.config=/logback.xml -jar /app.war + diff --git a/guest/spring-boot-app/pom.xml b/guest/spring-boot-app/pom.xml index ba57bbd5c5..c02eef7ef3 100644 --- a/guest/spring-boot-app/pom.xml +++ b/guest/spring-boot-app/pom.xml @@ -51,6 +51,22 @@ WebContent + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + com.stackify.Application + ${project.basedir}/docker + + + + + @@ -58,4 +74,4 @@ 8.0.43 - \ No newline at end of file + diff --git a/spring-boot-ops/pom.xml b/spring-boot-ops/pom.xml index b34fef8e6f..dce826dbb5 100644 --- a/spring-boot-ops/pom.xml +++ b/spring-boot-ops/pom.xml @@ -138,7 +138,6 @@ com.baeldung.webjar.WebjarsdemoApplication - ${project.basedir}/docker