Default Dockerfile generated for a Java sample application is:
FROM maven:3.5-jdk-8 as BUILD
COPY . /usr/src/app
RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package
FROM openjdk:8-jdk
ENV PORT 4567
EXPOSE 4567
COPY --from=BUILD /usr/src/app/target /opt/target
WORKDIR /opt/target
CMD ["/bin/bash", "-c", "find -type f -name '*.jar' | xargs java -jar"]
Some suggested improvements:
. The suggested tag for maven should be 3-jdk-10
. The second stage of the build should use JRE instead of JDK. So, the suggested tag would be jre-slim instead 8-jdk. This will create a leaner image.
Identified during hacking with @michelleN at #KubeCon
Default Dockerfile generated for a Java sample application is:
Some suggested improvements:
. The suggested tag for
maven
should be3-jdk-10
. The second stage of the build should use JRE instead of JDK. So, the suggested tag would bejre-slim
instead8-jdk
. This will create a leaner image.Identified during hacking with @michelleN at #KubeCon