failed to compute cache key: "/application-prod.yml" not found:

I am trying to deploy a java spring application as a Docker container.

The local docke build works fine. But when I try with fly.io I get an error.

Here is my Dockerfile

# I am using JAVA 11 ... on MAC
FROM --platform=linux/arm64 amazoncorretto:11
VOLUME /tmp

ADD target/liquido-backend-spring-6.0.0.jar liquido-backend-spring.jar
ADD application-prod.yml application-prod.yml    <====== THIS seems to be the problem

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/liquido-backend-spring.jar"]

fly launch output

App is not running, deploy...
==> Building image
Remote builder fly-builder-wild-frost-4148 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 5.3s (0/1)                                                                                                                                                                  
[+] Building 1.0s (6/6) FINISHED                                                                                                                                                         
 => [internal] load remote build context                                                                                                                                            0.0s
 => copy /context /                                                                                                                                                                 0.6s
 => [internal] load metadata for docker.io/library/amazoncorretto:11                                                                                                                0.3s
 => CANCELED [1/3] FROM docker.io/library/amazoncorretto:11@sha256:05e207c4c9f6b5e39822dbe505b73fab8c4628e19ee6d2ea3c8deedf6688eb25                                                 0.0s
 => => resolve docker.io/library/amazoncorretto:11@sha256:05e207c4c9f6b5e39822dbe505b73fab8c4628e19ee6d2ea3c8deedf6688eb25                                                          0.0s
 => => sha256:420f9550678ee7bf07f8065bc447c987d944739e64951579f9cacf597938c90e 3.09kB / 3.09kB                                                                                      0.0s
 => => sha256:05e207c4c9f6b5e39822dbe505b73fab8c4628e19ee6d2ea3c8deedf6688eb25 547B / 547B                                                                                          0.0s
 => => sha256:5842f39cd77a1bbe2bdc1f1bd7263720c46f212fab3623b7513ecfbbbac9c04f 742B / 742B                                                                                          0.0s
 => ERROR [2/3] ADD target/liquido-backend-spring-6.0.0.jar liquido-backend-spring.jar                                                                                              0.0s
 => ERROR [3/3] ADD application-prod.yml application-prod.yml                                                                                                                       0.0s
------
 > [2/3] ADD target/liquido-backend-spring-6.0.0.jar liquido-backend-spring.jar:
------
------
 > [3/3] ADD application-prod.yml application-prod.yml:
------
Error failed to fetch an image or build from source: error building: failed to compute cache key: "/application-prod.yml" not found: not found

I know the application-prod.yml It contains all my secrets. It is not packaged inside the JAR file. Therefore my Dockerfile contains the line ADD application-prod.yml application-prod.yml to add the file into the Docker image. But somehow fly.io does not catch up with that. Why? What am I missing?

Thanks a lot for any help or tips.

Kind regards, Robert

Solved it on my own.

The application-prod.yml file was accidentically excluded in the .dockerignore. That’s why it could be added.

New corrected .dockerignore

**/target     # I don't want all the classes and test reports in my docker image
!/target/liquido-backend*.jar    # but I DO want my JAR file :-)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.