mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-26 01:15:50 +00:00
created a dockerfile with single and multi step builds
This commit is contained in:
parent
051e40477f
commit
ba1fbbf0e5
1 changed files with 24 additions and 0 deletions
24
Dockerfile
Normal file
24
Dockerfile
Normal file
|
@ -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"]
|
Loading…
Reference in a new issue