From 9ca90af99a8a460f148f5945fd78773b53b00e06 Mon Sep 17 00:00:00 2001 From: Leonardo Zanivan Date: Thu, 7 Jun 2018 20:49:56 -0300 Subject: [PATCH] Add Dockerfile and Docker Maven plugin --- pom.xml | 67 +++++++++++++++++++++++++++++++ src/main/docker/Dockerfile | 1 + src/main/docker/Dockerfile.fatjar | 8 ++++ src/main/docker/Dockerfile.glibc | 24 +++++++++++ src/main/docker/Dockerfile.musl | 24 +++++++++++ 5 files changed, 124 insertions(+) create mode 120000 src/main/docker/Dockerfile create mode 100644 src/main/docker/Dockerfile.fatjar create mode 100644 src/main/docker/Dockerfile.glibc create mode 100644 src/main/docker/Dockerfile.musl diff --git a/pom.xml b/pom.xml index 7603cf905e7..7fadcd5e1de 100644 --- a/pom.xml +++ b/pom.xml @@ -308,6 +308,73 @@ + + + docker + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter-dockerfile + validate + + copy-resources + + + ${project.build.directory} + + + src/main/docker + true + + + + + + + + com.spotify + dockerfile-maven-plugin + 1.4.0 + + ${project.build.directory} + ${project.artifactId} + latest + + + -Xmx512m + + + + + org.codehaus.plexus + plexus-archiver + 3.4 + + + javax.activation + javax.activation-api + 1.2.0 + + + + + build-image + package + + build + + + + + + + + + diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile new file mode 120000 index 00000000000..07f0db50d2a --- /dev/null +++ b/src/main/docker/Dockerfile @@ -0,0 +1 @@ +Dockerfile.glibc \ No newline at end of file diff --git a/src/main/docker/Dockerfile.fatjar b/src/main/docker/Dockerfile.fatjar new file mode 100644 index 00000000000..ba820fc541e --- /dev/null +++ b/src/main/docker/Dockerfile.fatjar @@ -0,0 +1,8 @@ +FROM openjdk:10-jre-slim + +ADD spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar app.jar + +ARG JVM_OPTS +ENV JVM_OPTS=${JVM_OPTS} + +CMD java ${JVM_OPTS} -jar app.jar diff --git a/src/main/docker/Dockerfile.glibc b/src/main/docker/Dockerfile.glibc new file mode 100644 index 00000000000..7076c49cea1 --- /dev/null +++ b/src/main/docker/Dockerfile.glibc @@ -0,0 +1,24 @@ +FROM openjdk:10 as builder + +RUN jlink \ + --add-modules java.xml.bind,java.sql,java.naming,java.management,java.instrument,java.security.jgss \ + --verbose \ + --strip-debug \ + --compress 2 \ + --no-header-files \ + --no-man-pages \ + --output /opt/jre-minimal + +FROM panga/alpine:3.7-glibc2.25 + +COPY --from=builder /opt/jre-minimal /opt/jre-minimal + +ENV LANG=C.UTF-8 \ + PATH=${PATH}:/opt/jre-minimal/bin + +ADD modules /opt/app/modules + +ARG JVM_OPTS +ENV JVM_OPTS=${JVM_OPTS} + +CMD java ${JVM_OPTS} --upgrade-module-path /opt/app/modules --module spring.petclinic diff --git a/src/main/docker/Dockerfile.musl b/src/main/docker/Dockerfile.musl new file mode 100644 index 00000000000..86b3485f857 --- /dev/null +++ b/src/main/docker/Dockerfile.musl @@ -0,0 +1,24 @@ +FROM panga/openjdk10:jdk-alpine as builder + +RUN jlink \ + --add-modules java.xml.bind,java.sql,java.naming,java.management,java.instrument,java.security.jgss \ + --verbose \ + --strip-debug \ + --compress 2 \ + --no-header-files \ + --no-man-pages \ + --output /opt/jre-minimal + +FROM alpine:3.7 + +COPY --from=builder /opt/jre-minimal /opt/jre-minimal + +ENV LANG=C.UTF-8 \ + PATH=${PATH}:/opt/jre-minimal/bin + +ADD modules /opt/app/modules + +ARG JVM_OPTS +ENV JVM_OPTS=${JVM_OPTS} + +CMD java ${JVM_OPTS} --upgrade-module-path /opt/app/modules --module spring.petclinic