-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
base: 6.0
Are you sure you want to change the base?
Changes from all commits
8a057b6
a1e3780
8e5b9ee
d66c92e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,6 +7,8 @@ jobs: | |||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- uses: actions/checkout@v5 | ||||||
with: | ||||||
submodules: true | ||||||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add this? It's not broken and it has nothing to do with the purpose of this PR. Please revert.
Suggested change
|
||||||
|
||||||
- name: Set up Python ${{ matrix.python-version }} | ||||||
uses: actions/setup-python@v5 | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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` | ||||||||||||||
|
||||||||||||||
|
@@ -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. | ||||||||||||||
|
@@ -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. | ||||||||||||||
Comment on lines
+340
to
+342
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davisagli can I get a confirmation about this change?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stevepiercy It is correct that the It's incorrect to say that the old approach of referencing content profiles in the distribution is deprecated. Both approaches for creating example content are still supported. It's fine to say that this one is the recommended one (since it requires less configuration). I don't understand why any of this is in this particular pull request, which claims to be about adding documentation for an interactive shell, which is unrelated to distributions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a separate PR to clean up the outdated references to the plone.volto:default-homepage profile, so that we can focus on the interactive shell docs here. |
||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
## Limit available distributions | ||||||||||||||
|
||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
+111
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, wait a minute. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a quite old list of version pins which was probably left over from Plone 5 where volto wasn't included. Neither the ADDONS nor PROFILES environment variables should be needed here; the plone-backend image already contains appropriate versions. |
||
|
||
frontend: | ||
image: 'myfrontend:latest' | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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. | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are multiple traditions for how to install Plone. It'd be clearer to say buildout-based instead of traditional. Note, we already have documentation for doing this outside the context of a Docker container in https://6.docs.plone.org/admin-guide/run-plone.html#run-a-debug-console where we call it a debug console rather than an interactive shell. I don't care what we call it but we should be consistent. |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
### Using docker exec | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
If you have a running Plone container, you can start an interactive shell using `docker exec`: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
docker exec -it <container_name> /bin/bash | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docker exec -it <container_name> /bin/bash
Suggested change
|
||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Once inside the container, you can start the Plone debug console: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
bin/instance debug | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's a step missing before this one. I followed the instructions in https://6.docs.plone.org/install/containers/index.html through "Access your Plone site" to set up the containers. The docker exec -it plone6-backend /bin/bash
root@9ae16356b1a2:/app# bin/instance debug
bash: bin/instance: No such file or directory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Within the plone-backend container, the correct command is |
||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
### Using docker run | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Alternatively, you can start a new container instance specifically for debugging: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
docker run -it --rm plone/plone-backend:{PLONE_BACKEND_MINOR_VERSION} /bin/bash | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Then start the debug console: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
bin/instance debug | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment. I have no |
||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
### Using Docker Compose | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
If you're using Docker Compose, you can run an interactive shell with: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
docker compose exec backend /bin/bash | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Then start the debug console: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
bin/instance debug | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Or run it directly in one command: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```shell | ||||||||||||||||||||||||||
docker compose exec backend bin/instance debug | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
### Accessing the Plone site | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Once in the debug console, you can access your Plone site and perform debugging operations: | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This information isn't specific to a console that was started in a container. It should go under https://6.docs.plone.org/admin-guide/run-plone.html#run-a-debug-console instead. |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
```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'] | ||||||||||||||||||||||||||
Comment on lines
+235
to
+240
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assume code uses Black formatting.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# 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 | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add this? It's not broken and it has nothing to do with the purpose of this PR. Please revert.