2020-04-18 18:52:35 +00:00
|
|
|
# Use the official maven/Java 8 image to create a build artifact.
|
|
|
|
# https://hub.docker.com/_/maven
|
|
|
|
FROM maven:3.6.3-jdk-11-slim as builder
|
|
|
|
|
|
|
|
# Copy local code to the container image.
|
|
|
|
WORKDIR /app
|
|
|
|
COPY pom.xml .
|
|
|
|
COPY src ./src
|
|
|
|
|
|
|
|
# Build a release artifact.
|
|
|
|
RUN mvn package -DskipTests
|
|
|
|
|
|
|
|
# Use AdoptOpenJDK for base image.
|
|
|
|
# It's important to use OpenJDK 8u191 or above that has container support enabled.
|
|
|
|
# https://hub.docker.com/r/adoptopenjdk/openjdk8
|
|
|
|
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
|
2020-04-18 19:03:03 +00:00
|
|
|
FROM adoptopenjdk/openjdk11:jdk-11.0.6_10-alpine-slim
|
2020-04-18 18:52:35 +00:00
|
|
|
|
|
|
|
# Copy the jar to the production image from the builder stage.
|
|
|
|
COPY --from=builder /app/target/chuckjokes-*.jar /chuckjokes.jar
|
|
|
|
|
|
|
|
# Run the web service on container startup.
|
|
|
|
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/chuckjokes.jar"]
|