dockerfile:
JavaScript
x
FROM maven as builder
# Set the working directory.
WORKDIR /usr/src/mymaven
COPY ./ /usr/src/mymaven
CMD [ "maven:3.3-jdk-8" , "mvn" , "clean" , "install" ]
FROM openjdk:8
COPY --from=builder /usr/src/mymaven/target /usr/src/myapp
WORKDIR /usr/src/myapp
CMD ["java", "-jar" , "Build-Backend-0.0.1-SNAPSHOT.jar"]
In local build is successful using the command:
JavaScript
docker build -t javaservice .
But when trying to upload image to google cloud run using command:
JavaScript
gcloud builds submit --tag gcr.io/$(gcloud config get-value project)/javaservice
It gives error:
JavaScript
Step 6/8 : COPY --from=builder /usr/src/mymaven/target /usr/src/myapp
COPY failed: stat /var/lib/docker/overlay2/201005fffe25fce26b6ef6067586ae02dd20a0ad7d63b846d5ee6260d833d52d/merged/usr/src/mymaven/target: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
What might be wrong here?
Advertisement
Answer
Couldn’t find an answer so posting the solution that I found on my own.
If you can build docker images on local machine but google cloud run is failing for whatever reason, you can push the locally made image directly to google container registry.
JavaScript
gcloud auth configure-docker #integrate gcloud to docker
docker build . --tag gcr.io/[PROJECT-ID]/[IMAGENAME]
docker push gcr.io/[PROJECT-ID]/[IMAGENAME]
Source: https://cloud.google.com/run/docs/building/containers