From ba1fbbf0e592e928a8a40aea4869f1047e0c1ead Mon Sep 17 00:00:00 2001 From: GasparAM Date: Tue, 11 Apr 2023 14:45:15 +0400 Subject: [PATCH] created a dockerfile with single and multi step builds --- Dockerfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4a7c5cbbe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Create Dockerfile for Spring-petclinic application using pre-built artifact + +# FROM alpine:latest +# ENV JAR=spring-petclinic-3.0.3.jar +# RUN apk --no-cache add openjdk17-jre-headless +# COPY ./target/${JAR} ./ +# EXPOSE 8080 +# CMD ["/bin/sh", "-c", "/usr/bin/java -jar ${JAR}"] + +# Create multi-stage Dockerfile for Spring-petclinic application + +FROM alpine:latest AS builder +RUN apk --no-cache add openjdk17 +WORKDIR /tmp +COPY ./ ./ +RUN ./mvnw clean ; ./mvnw package + +FROM alpine:latest +ENV JAR=spring-petclinic-3.0.3.jar +RUN apk --no-cache add openjdk17-jre-headless +WORKDIR /home +COPY --from=builder /tmp/target/spring-*.jar ./ +EXPOSE 8080 +CMD ["/bin/sh", "-c", "/usr/bin/java -jar /home/spring-*.jar"] \ No newline at end of file