When Cloud Run runs a container image, the container fails differently than when I run it locally.
I added this try/except in app/main.py to debug the divergent behaviors:
print(f'cwd is {os.getcwd()}')
try:
from .make_sticker.config import StickerConfig
print('relative worked')
except:
from make_sticker.config import StickerConfig
print('except worked')
When I run the container locally, the app logs 'except worked'. When I run the container in Cloud Run, the app fails out of the except and does not log anything.
This is my Dockerfile:
FROM python:3.12
WORKDIR /code
COPY app/requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY app/ /code/app
ENV PYTHONPATH=/code/app
WORKDIR /code/app
RUN ls -la
EXPOSE 5001
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5001"]
What is going on here?