Portal object not available with custom-built Plone 6 backend on docker

Continuing the discussion from The production way to work with custom Plone backend images:

I'm working with a custom production image, built using the approach :point_up_2: documented in the last post. Everything was great until I tried to retrieve the portal using plone.api

I have an add-on that fails when it reaches the following line of code:

portal = api.portal.get()

With this error:
plone.api.exc.CannotGetPortalError: Unable to get the portal object. More info on plone.api.exc — Plone Documentation v5.2

When I go to the linked documentation it mentions that retrieving the portal object fails in debug mode. I'm pretty sure I'm in production mode though.

Nevermind me, nothing to see here. Was probably half awake.
Once I located the code properly, in this case a function within a class, the api was able to call the portal object as expected.

class HomeSlider(CollectionView):
    def __call__(self):
        # Implement your own actions:
        portal = api.portal.get()