Dockerfile works locally but not in Render, exception for gradle

I have a dockerfile for my java spring boot app on gradle

And got the following exception on Render

Nov 15 03:06:53 PM  #19 1.285 * Exception is:
Nov 15 03:06:53 PM  #19 1.285 net.rubygrapefruit.platform.NativeException: Could not set process working directory to '/usr/src/java-code': could not setcwd() (errno 2: No such file or directory)

on
RUN gradle bootJar -i --stacktrace

My dockerfile is:

FROM gradle:6.9.3-jdk11 as cache
RUN mkdir -p /home/gradle/cache_home
ENV GRADLE_USER_HOME /home/gradle/cache_home
COPY build.gradle /home/gradle/java-code/
WORKDIR /home/gradle/java-code
RUN gradle clean build -i --stacktrace

FROM gradle:6.9.3-jdk11 as builder
COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle
COPY . /usr/src/java-code/
COPY .env /usr/src/java-code/
WORKDIR /usr/src/java-code
RUN gradle bootJar -i --stacktrace

FROM openjdk:11-jre-slim
EXPOSE 8080
USER root
WORKDIR /usr/src/java-app
COPY --from=builder /usr/src/java-code/build/libs/*.jar ./app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]

Seems like render couldn’t run
gradle bootJar command

I changed my dockerfile to have 2 layers indstead of 3 with only build command
Now I deployed successfully

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