user22415569
user22415569

Reputation: 21

Cloud Run error: File not found (but it's there)

I keep getting file not found error with a docker image on Cloud Run:

{
insertId: "64e042dc00012912dc1845f7"
labels: {6}
logName: "projects/vvchatapp-383303/logs/run.googleapis.com%2Fstderr"
receiveTimestamp: "2023-08-19T04:19:40.415647981Z"
resource: {2}
textPayload: "FileNotFoundError: [Errno 2] No such file or directory: './frontend/investpr/dist/index.html'"
timestamp: "2023-08-19T04:19:40.076050Z"
}

However the file is in the image when I build the image locally (and it runs without errors on locally build images form the same Dockerfile).

Any ideas what might be the problem or how to debug it in Cloud Run?

Running the same image locally.

Upvotes: 2

Views: 1692

Answers (2)

Daisuke Horii
Daisuke Horii

Reputation: 83

Since you mentioned that your Docker image works fine locally, I'm wondering if you are using Cloud Build to build the container image for Cloud Run, as shown below:

gcloud builds submit --tag gcr.io/PROJECT_ID/helloworld

If this is the case, please check whether the directory contains a .gitignore file that might include some essential files. Cloud Build uses .gitignore to ignore files, so removing essential files from .gitignore (or deleting .gitignore) might solve the problem.

Upvotes: 0

Andrew Arrow
Andrew Arrow

Reputation: 4585

It's that ./frontend/ path that's the problem. In Google Cloud Run you have no control over the working directory. So what is . ? Just use an absolute path like /root/path/somewhere/index.html and then you don't have to worry about the working directory.

Upvotes: 1

Related Questions