gclayburg / dockerPreparePlugin

Gradle plugin to generate docker layer-friendly directory for spring boot applications
Apache License 2.0
48 stars 8 forks source link

Spring boot 2.5.x layer does not exist error #10

Open thiaguten opened 2 years ago

thiaguten commented 2 years ago

Hi,

I'm using this plugin to create a Dockerfile with correct layers for my springboot project, but I'm facing a strange error in my CI during docker build process and I have no clue what is wrong so I open this issue for some help.

Snippet of the error:

2021-11-09T13:25:56.3034681Z Step 9/19 : ADD snapshotLayer3/ /home/springboot/app/ 2021-11-09T13:25:57.0138269Z ---> 7c22a09f9c43 2021-11-09T13:25:57.0138749Z Step 10/19 : ADD classesLayer4/ /home/springboot/app/ 2021-11-09T13:25:58.0385717Z failed to export image: failed to create image: failed to get layer sha256:89bc8fa8b17002644dbde60c1e677adfce8c26d60f8c24c3dbb32a4a9d36c3b9: layer does not exist 2021-11-09T13:25:58.0512683Z ##[error]failed to export image: failed to create image: failed to get layer sha256:89bc8fa8b17002644dbde60c1e677adfce8c26d60f8c24c3dbb32a4a9d36c3b9: layer does not exist 2021-11-09T13:25:58.0528976Z ##[error]The process '/usr/bin/docker' failed with exit code 1 2021-11-09T13:25:58.0556179Z ##[section]Finishing: Build an image

I'm using SpringBoot 2.5.6 with Java 11 and Gradle 7.2

The complete CI Build image log, Dockerfile and build.gradle are attached .

CI-error.txt Dockerfile.txt build.gradle.txt

Thanks for all the help.

thiaguten commented 2 years ago

I think this error is related with docker server engine version running on Azure because locally on my machine with docker version 20.10.8 the build command works perfectly and the image was created.

$ cd build/docker $ docker build -t myorg/demo:latest .

So after searching about this error I found this issue: COPY fail in multistage build: layer does not exist

The workaround was to put RUN true between the ADD commands in my Dockerfile (attached)

Dockerfile.txt

So if anyone is facing this problem, here is a possible solution. I don't think it's a pretty solution though