Docker Build Getting Failed, during Railway Deployment. Working fine in Local

falcon-ssh
HOBBY

7 months ago

Gradle+Docker Based SpringBoot Application

While Deploying to Railway My Build is getting failed with Reason,
*
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref kocke7udfagcoizp4nqtcbnjm::j1tte7ce5zsn1ky14in8kkkkw: "/build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar": not found
*
. Looks like This is due to COPY command is not working properly.I tried following

  1. Using no-cache option in docker build phase

  2. Made sure /build/lib folder is not in .gitIgnore

  3. Tried deleting the service and created again.

My DockerFile (Ignore the Unnecessary Stepts, added them as part of debugging)

# Use openjdk as base image FROM openjdk:17-jdk-slim # Set working directory inside container WORKDIR /app # Install gradle to build the project RUN apt-get update && apt-get install -y wget unzip \ && wget https://services.gradle.org/distributions/gradle-7.3-bin.zip \ && unzip gradle-7.3-bin.zip \ && mv gradle-7.3 /opt/gradle \ && ln -s /opt/gradle/bin/gradle /usr/bin/gradle # Copy project files into the container (this happens after the Gradle installation) COPY . . # Force cache invalidation by creating a dummy file before build RUN touch /tmp/fresh-build-trigger && rm -rf ~/.gradle/caches/ && ./gradlew clean build --no-daemon --info # Run gradle build (this will generate the jar) # Clear the Gradle cache and build project with fresh dependencies RUN echo "Cleaning Gradle cache and rebuilding dependencies at $(date)" && \ rm -rf ~/.gradle/caches/ && \ ./gradlew clean build --no-daemon --refresh-dependencies --info # Verify if the jar file is created (this checks the build/libs directory) RUN ls -la /app/build/libs/ # Wait for the JAR file to exist before continuing RUN until [ -f /app/build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar ]; do \ echo "Waiting for JAR file to be created..."; \ sleep 10; \ done # Expose port 8080 EXPOSE 8080 # Copy the generated jar file into the container (this step should happen after the jar is built) COPY build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar myapp.jar # Run the jar file ENTRYPOINT ["java", "-jar", "myapp.jar"]

Find the Logs Below

4 [internal] load .dockerignore

4 transferring context: 2B done

4 DONE 0.0s

5 [internal] load build context

5 transferring context: 188.81kB 0.0s done

5 DONE 0.0s

6 [4/8] COPY . .

6 CACHED

7 [5/8] RUN ./gradlew clean build --no-daemon --info

7 CACHED

8 [6/8] RUN ls -la /app/build/libs/

8 CACHED

9 [7/8] RUN if [ ! -f build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar ]; then echo "Jar file not found"; exit 1; fi

9 CACHED

10 [3/8] RUN apt-get update && apt-get install -y wget unzip && wget https://services.gradle.org/distributions/[gradle-7.3-bin.zip](gradle-7.3-bin.zip) && unzip gradle-7.3-bin.zip && mv gradle-7.3 /opt/gradle && ln -s /opt/gradle/bin/gradle /usr/bin/gradle

10 CACHED

11 [8/8] COPY build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar myapp.jar

11 ERROR: failed to calculate checksum of ref kocke7udfagcoizp4nqtcbnjm::j1tte7ce5zsn1ky14in8kkkkw: "/build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar": not found

12 [1/8] FROM docker.io/library/openjdk:17-jdk-slim@sha256:aaa3b3cb27e3e520b8f116863d0580c438ed55ecfa0bc126b41f68c3f62f9774

12 resolve docker.io/library/openjdk:17-jdk-slim@sha256:aaa3b3cb27e3e520b8f116863d0580c438ed55ecfa0bc126b41f68c3f62f9774 done

12 sha256:6ce99fdf16e86bd02f6ad66a0e1334878528b5a4b5487850a76e0c08a7a27d56 0B / 187.90MB

12 sha256:44d3aa8d076675d49d85180b0ced9daef210fe4fdff4bdbb422b9cf384e591d0 0B / 1.58MB

12 …

13 [2/8] WORKDIR /app

13 CANCELED

[8/8] COPY build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar myapp.jar:

Dockerfile:30

28 |

29 | # Copy the generated jar file into the container (this step should happen after the jar is built)

30 | >>> COPY build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar myapp.jar

31 |

32 | # Run the jar file

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref kocke7udfagcoizp4nqtcbnjm::j1tte7ce5zsn1ky14in8kkkkw: "/build/libs/exam-practice-platform-0.0.1-SNAPSHOT.jar": not found

View Deploy details

Used Build Commnd: docker build --no-cache -t exam-practice-platform-app .

ⓘ Deployment information is only viewable by project members and Railway employees.

1 Replies

7 months ago

Hey!

So sorry for the late reply here, but looks like you got it working? gonna mark this as solved for now, but feel free to re-open if needed!

Best,
Brody


Docker Build Getting Failed, during Railway Deployment. Working fine in Local - Railway Help Station