google cloud platform – File Not Found error during Docker container run with existing file

I’m trying to deploy a Google Cloud Run application in Python and when the code tries to open a configuration file (yaml) an error occurs saying File Not Found.

However, the file was uploaded during the build phase and the same Python module that tries to open the file is able to find it. See how I tested it:

from rapport_engine.conf.agent import AgentConfiguration
import yaml
import pathlib

def list_files(directory):
    for file in pathlib.Path(directory).rglob('*'):
        if file.is_file():
            print(file)

def load(path: str) -> AgentConfiguration:
    list_files('/etc/rapport_engine')
    with open(path, "r") as f:
        contents = yaml.safe_load(f)
    return AgentConfiguration(contents)

The ‘path’ argument in the ‘load’ function says ‘/etc/rapport_engine/agent.conf.yaml’ as it should.

As one can see in the image,the file is shown in the call for the ‘list_files’ function but when try to open it, got File Not Found error.

Log screenshot

I’ve tried deploying several times, always the same error.

Read more here: Source link