Skip to content

Not support for multi-stage build #2

Description

@ripper2hl

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/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions