Solomon Tolu Samuel
08/07/2021, 8:43 PMFROM openjdk:13 AS builder
RUN java --version
RUN mkdir /application
WORKDIR /application
COPY ./ ./
RUN ./gradlew clean build
RUN ls -al build/libs/
...
version: "3"
services:
myapp:
build: .
And this is the error i keep getting:
ERROR [6/7] RUN ./gradlew clean build 1.9s
------
> [6/7] RUN ./gradlew clean build:
#10 1.339 /bin/sh: ./gradlew: No such file or directory
------
executor failed running [/bin/sh -c ./gradlew clean build]: exit code: 127
ERROR: Service 'myapp' failed to build : Build failed
After trying lots of solutions, i decided to use another approach:
FROM openjdk:8-jre-alpine
ENV APPLICATION_USER ktor
RUN adduser -D -g '' $APPLICATION_USER
RUN mkdir /app
RUN chown -R $APPLICATION_USER /app
USER $APPLICATION_USER
COPY ./build/libs/app.jar /app/app.jar
WORKDIR /app
CMD ["java","-server","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-XX:InitialRAMFraction=2","-XX:MinRAMFraction=2","-XX:MaxRAMFraction=2","-XX:+UseG1GC","-XX:MaxGCPauseMillis=100","-XX:+UseStringDeduplication","-jar","app.jar"]
And i also got a similar error:
ERROR [5/6] COPY ./build/libs/app.jar /app/app.jar 0.0s
------
> [5/6] COPY ./build/libs/app.jar /app/app.jar:
------
failed to compute cache key: "/build/libs/app.jar" not found: not found
hfhbd
08/07/2021, 8:59 PMFROM openjdk:13 AS builder
RUN java --version
RUN mkdir /application
WORKDIR /application
COPY . . <- use .
RUN ./gradlew clean build
RUN ls -al build/libs/
Did you add the .gradlew
to .dockerignore
?
If you want to use a builder
you have to include the consumer too 😄
Just check your paths with ls
.
Guess: in 2nd COPY:
COPY ./build/libs/app.jar /app/app.jar
should it not be COPY build/libs/app.jar /app/app.jar
?Solomon Tolu Samuel
08/07/2021, 9:53 PMdave08
08/08/2021, 2:14 AM