this is my dockerfile:
ARG BUILD_PATH=/usr/app
# Building image
FROM maven:3.8.3-openjdk-17 AS maven
ARG BUILD_PATH
RUN mkdir -p $BUILD_PATH
WORKDIR $BUILD_PATH
COPY . .
RUN mvn clean package -Dmaven.test.skip
# Final image
FROM eclipse-temurin:17-jdk-alpine
ARG BUILD_PATH
COPY --from=maven $BUILD_PATH/target/app.jar /
ENTRYPOINT ["java", "-jar", "/app.jar"]
Every time I build my application using docker build -t name ., docker will build the maven image again, which will download all the project's dependencies and package the app and that takes a while. I want to know if there is a way to make docker reuse an image from an earlier build (which will have all the project's dependencies already downloaded) to package the jar that will be used in the final build.