The mulit stage build is not supported for current image, for example when you have the next Dockerfile works fine
FROM maven:alpine AS build
ADD src /usr/src/app/src
ADD pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml clean package -Dmaven.test.skip=true
RUN ls -la /usr/src/app/target/
FROM openjdk:alpine
COPY --from=build /usr/src/app/target/app.jar ./app.jar
EXPOSE 8080
But when i use the spring-boot-docker-base image this doesn't work
FROM maven:alpine AS build
ADD src /usr/src/app/src
ADD pom.xml /usr/src/app/
RUN mvn -f /usr/src/app/pom.xml clean package -Dmaven.test.skip=true
RUN ls -la /usr/src/app/target/
FROM etiennek/spring-boot
COPY --from=build /usr/src/app/target/app.jar ./app.jar
EXPOSE 8080
This is the output:
$ docker build . -t sepomex
Sending build context to Docker daemon 23.05MB
Step 1/7 : FROM maven:alpine AS build
---> 7445f83cd169
Step 2/7 : ADD src /usr/src/app/src
---> Using cache
---> 16084bce6aba
Step 3/7 : ADD pom.xml /usr/src/app/
---> Using cache
---> 78ba6ac64513
Step 4/7 : RUN mvn -f /usr/src/app/pom.xml clean package -Dmaven.test.skip=true
---> Using cache
---> 6fb46a02162f
Step 5/7 : FROM etiennek/spring-boot
# Executing 5 build triggers
---> Using cache
---> Using cache
COPY failed: stat /var/lib/docker/tmp/docker-builder953042355/app.jar: no such file or directory
perales at MacBook-Pro-de-Israel-Perales in ~/Documents/Documentos/git/sepomex on master*
https://aboullaite.me/multi-stage-docker-java/
The mulit stage build is not supported for current image, for example when you have the next
Dockerfileworks fineBut when i use the spring-boot-docker-base image this doesn't work
This is the output:
https://aboullaite.me/multi-stage-docker-java/