Reputation: 157
I am new to docker. I have a maven wrapper which build package my application and copy the deployables into new folder and then run it. I am getting this error.
COPY failed: stat /var/lib/docker/tmp/docker-builder102689450/app/q-runner/target/q-runner-0.0.1-runner.jar: no such file or directory
Why should the file searched in above location when I mentioned to copy from /app/.
My docker file is
# docker build -f Dockerfile.build -t abc/notify-build .
FROM adoptopenjdk/openjdk14:ubi
WORKDIR /app
COPY ./ /app
RUN chmod +x ./mvnw && \
./mvnw package
ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0
COPY /app/target/*-runner.jar /deployments/app.jar
CMD java -jar /deployments/app.jar
Upvotes: 0
Views: 4400
Reputation: 157
I have changed this into two stage build and solved it
#stage1
FROM adoptopenjdk/openjdk14:ubi as builder
RUN mkdir build
COPY . /build
WORKDIR /build
RUN chmod +x ./mvnw && \
./mvnw package
#stage2
FROM adoptopenjdk/openjdk14:ubi
COPY --from=builder /build/q-runner/target/lib/* /deployments/lib/
COPY --from=builder /build/q-runner/target/*-runner.jar /deployments/app.jar
ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0
CMD java -jar /deployments/app.jar
Upvotes: 1