I am trying to deploy my FastAPI app on Cloud Run, and in the Dockerfile I'd like to copy a file on my GCS Bucket and read it in the API. It somehow does not copy the file.
This is the copy lines in my Dockerfile:
FROM google/cloud-sdk AS gcloud
RUN mkdir ./models
RUN gsutil cp gs://rim-models/model_1.pkl ./models/model_1.pkl
And when I created an image with gcloud builds submit --tag gcr.io/project-id/api-name --timeout=3600, it shows that the file was copied:
Copying gs://rim-models/model_1.pkl ...
- [1 files][399.8 KiB/399.8 KiB]
Operation completed over 1 objects/399.8 KiB.
However, I got this error in the API:
FileNotFoundError: [Errno 2] No such file or directory: 'models/model_1.pkl'
When I run the command gsutil cp gs://rim-models/model_1.pkl ./models/model_1.pkl locally, it does copy the file model_1.pkl to my local directory models. So why did it not work when I deployed the app to Cloud Run?
EDIT: After changing all models paths to either all relative or all absolute, the error remains.