Interactive shell for debugging with Plone 6 docker-compose: The wsgi equivalent of bin/instance debug

Today I wanted to do some interactive debugging.

Old way

The old way before wsgi tended to look like

bin/instance debug

You'll get an interactive prompt. The root of your Zope will be called app and, most likely your Plone site will be called Plone

>>> plonesite = app.Plone

and then do what you want on the interactive prompt.

New way

For the default docker-compose setup this works:

docker compose exec backend ./docker-entrypoint.sh console

and then work the prompt as expected

>>> plonesite = app.Plone

Background Research and round-about way

DON'T DO IT THIS WAY. I'VE LEFT THIS HERE FOR REFERENCE PURPOSES
I found some documentation on using zconsole for debugging

And got some help over in the Plone Slack channel from @tiberiuichim
He pointed me to The Big List of Small Volto Rules · Issue #2810 · plone/volto · GitHub
With some further guidance from @tiberiuichim I finally came to this as the solution:
This way involves modifing docker-compose.yml to set bash as the default command.
This prevents the instance from starting as normal.

version: "3"

services:

  backend:
    #build: .
    image: <the image>
    command: bash
    tty: true

Once running (typically launched with docker compose up -d)

The following series of commands launch an interactive shell

docker compose exec backend bash
./docker-entrypoint.sh bash
bin/zconsole debug etc/relstorage.conf

You'll see the prompt:
and it works as expected

>>>
>>> plonesite = app.Plone

Note the use of relstorage.conf
If you use zeo storage use zeo.conf instead
if you use file storage (Data.fs), use zope.conf instead

It looks in the folder where the for the conf files
I was successful with the plone-backend docker image.

3 Likes