Skip to content

Added recipe to have an interactive shell when using docker #1967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
url: https://docs.plone.org
steps:
- uses: actions/checkout@v5
with:
submodules: true
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Set up Python 3.12
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand Down
17 changes: 14 additions & 3 deletions docs/developer-guide/create-a-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,16 @@ As an example, the configuration for a new Plone site with Volto as its frontend
"plonetheme.barceloneta:default",
"plone.volto:default"
],
"content": [
"plone.volto:default-homepage"
]
"content": []
}
```

```{note}
The `plone.volto:default-homepage` profile was removed from `plone.volto` in version 5.
For creating example content, use the `content` folder with exported content instead of profiles.
See the {ref}`add-example-content-label` section below for details.
```


### `schema.json`

Expand Down Expand Up @@ -319,6 +323,8 @@ Finally, add it to your {file}`profiles.json` file.
```


(add-example-content-label)=

## Add example content

The distribution loads its content from JSON data in the `content` folder.
Expand All @@ -331,6 +337,11 @@ bin/export-distribution path/to/zope.conf Plone

In the example above, `Plone` is the ID of the Plone site to export.

```{note}
This is the recommended approach for creating example content in distributions.
The old approach of using profiles like `plone.volto:default-homepage` has been deprecated and removed from `plone.volto` in version 5.
```


## Limit available distributions

Expand Down
3 changes: 2 additions & 1 deletion docs/install/containers/images/frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ services:
environment:
- SITE=Plone
- 'ADDONS=plone.restapi==8.21.0 plone.volto==4.0.0a3 plone.rest==2.0.0a2 plone.app.iterate==4.0.2 plone.app.vocabularies==4.3.0'
- 'PROFILES=plone.volto:default-homepage'
# Note: plone.volto:default-homepage profile was removed in version 5
# Use content export/import instead for example content

frontend:
image: 'myfrontend:latest'
Expand Down
86 changes: 86 additions & 0 deletions docs/install/containers/recipes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,89 @@ docker compose run backend pack
The above command assumes that the service that runs the Plone instance is named `backend`.
Otherwise replace `backend` with your container's name.


## Interactive shell for debugging

When developing or troubleshooting Plone applications in Docker containers, you may need an interactive Python shell with the Plone environment loaded.
This is the Docker equivalent of the `bin/instance debug` command used in traditional Plone installations.

### Using docker exec

If you have a running Plone container, you can start an interactive shell using `docker exec`:

```shell
docker exec -it <container_name> /bin/bash
```

Once inside the container, you can start the Plone debug console:

```shell
bin/instance debug
```

### Using docker run

Alternatively, you can start a new container instance specifically for debugging:

```shell
docker run -it --rm plone/plone-backend:{PLONE_BACKEND_MINOR_VERSION} /bin/bash
```

Then start the debug console:

```shell
bin/instance debug
```

### Using Docker Compose

If you're using Docker Compose, you can run an interactive shell with:

```shell
docker compose exec backend /bin/bash
```

Then start the debug console:

```shell
bin/instance debug
```

Or run it directly in one command:

```shell
docker compose exec backend bin/instance debug
```

### Accessing the Plone site

Once in the debug console, you can access your Plone site and perform debugging operations:

```python
# Access the root application
app = self.app

# Access your Plone site (replace 'Plone' with your site ID)
site = app['Plone']

# Access content
folder = site['my-folder']
item = folder['my-item']

# Set up a fake request for testing
from Testing.makerequest import makerequest
from zope.globalrequest import setRequest

app = makerequest(app)
setRequest(app.REQUEST)
```

### Exiting the debug console

To exit the debug console, use {kbd}`ctrl-d` or type `exit()`.

```{note}
The interactive shell provides full access to your Plone environment and database.
Use it carefully in production environments.
```