Merge pull request #102 from thaJeztah/improve-java-worker

Optimize java-worker image
This commit is contained in:
Mano Marks 2018-01-04 10:24:25 -08:00 committed by GitHub
commit e5dfa4747b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,19 +1,17 @@
FROM java:openjdk-8-jdk-alpine FROM maven:3.5-jdk-8-alpine AS build
RUN MAVEN_VERSION=3.3.3 \
&& cd /usr/share \
&& wget http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz -O - | tar xzf - \
&& mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
WORKDIR /code WORKDIR /code
ADD pom.xml /code/pom.xml COPY pom.xml /code/pom.xml
RUN ["mvn", "dependency:resolve"] RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"] RUN ["mvn", "verify"]
# Adding source, compile and package into a fat jar # Adding source, compile and package into a fat jar
ADD src/main /code/src/main COPY ["src/main", "/code/src/main"]
RUN ["mvn", "package"] RUN ["mvn", "package"]
CMD ["java", "-jar", "target/worker-jar-with-dependencies.jar"] FROM openjdk:8-jre-alpine
COPY --from=build /code/target/worker-jar-with-dependencies.jar /
CMD ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-jar", "/worker-jar-with-dependencies.jar"]