Skip to content

Commit

Permalink
Merge pull request #1874 from plone/erral-zopeini
Browse files Browse the repository at this point in the history
Add documentation on how to customize containers with custom  files
  • Loading branch information
davisagli authored Mar 6, 2025
2 parents 96eed09 + c9cf548 commit f9f1716
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/install/containers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ The Plone 6 container images are compliant with the [Open Container Initiative (
They should work with any OCI-compliant container engine for developing, managing, and running Plone 6 images.
Two popular options include [podman](https://podman.io/) and [Docker](https://www.docker.com/products/docker-desktop/).

The community provides official images that could be used for standalone Plone installations.
## Resources

The community provides {doc}`images/index` that you can use for standalone Plone installations.
These images support a variety of installation options.
You can choose from Classic UI or the new frontend, or specialized databases using ZEO or a relational database.
You can choose from Volto or Classic UI for a frontend, or specialized databases using ZEO or a relational database.

The {doc}`examples/index` and {doc}`recipes/index` provide configuration for proxy servers, load balancers, and caching services.

```{toctree}
:maxdepth: 2
:hidden: true
:hidden:
images/index
examples/index
recipes/index
```

## Getting started
Expand Down
120 changes: 120 additions & 0 deletions docs/install/containers/recipes/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
myst:
html_meta:
"description": "Plone 6 Docker image recipes"
"property=og:description": "Plone 6 Docker image recipes"
"property=og:title": "Plone 6 image recipes"
"keywords": "Plone 6, install, installation, Docker, containers, official images"
---

# Docker recipes

This chapter offers some useful recipes when working with Plone containers.


## Remove access log from Plone containers

When you generate a project using [Cookieplone](https://github.com/plone/cookieplone), it creates Plone containers for your project that are based on the official [`plone/plone-backend`](https://github.com/plone/plone-backend) images.

When you run your container or the official `plone/plone-backend` image with logging, the output mixes both the event log and the access log, making it hard to follow the logs you may have added to your application.
In such cases, you may have a Docker Compose setup with several components including a proxy server that already provides access logs.
Instead of duplicating the logging output, it is common to remove the access logging from the Plone container.

To do so, create a custom {file}`zope.ini` file in your project's {file}`backend` folder with the following content.

```{code-block} ini
:emphasize-lines: 17-20
[app:zope]
use = egg:Zope#main
zope_conf = %(here)s/%(config_file)s
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 8080
threads = 2
clear_untrusted_proxy_headers = false
max_request_body_size = 1073741824
[filter:translogger]
use = egg:Paste#translogger
setup_console_handler = False
[pipeline:main]
pipeline =
egg:Zope#httpexceptions
zope
[loggers]
keys = root, waitress.queue, waitress, wsgi
[handlers]
keys = accesslog, eventlog
[formatters]
keys = generic, message
[formatter_generic]
format = %(asctime)s %(levelname)s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S
[formatter_message]
format = %(message)s
[logger_root]
level = INFO
handlers = eventlog
[logger_waitress.queue]
level = INFO
handlers = eventlog
qualname = waitress.queue
propagate = 0
[logger_waitress]
level = INFO
handlers = eventlog
qualname = waitress
propagate = 0
[logger_wsgi]
level = WARN
handlers = accesslog
qualname = wsgi
propagate = 0
[handler_accesslog]
class = StreamHandler
args = (sys.stdout,)
level = INFO
formatter = message
[handler_eventlog]
class = StreamHandler
args = (sys.stderr,)
level = INFO
formatter = generic
```

Comparing this file with the [original `zope.ini` file](https://github.com/plone/plone-backend/blob/6.1.x/skeleton/etc/zope.ini) that comes with the `plone/plone-backend` container, you may realize that the only change is the `translogger` configuration was removed from the `pipeline` section.
This [`translogger` middleware produces logs in the Apache Combined Log Format](https://docs.pylonsproject.org/projects/waitress/en/latest/logging.html).
The above configuration removes it from the setup.

After adding the {file}`zope.ini` file in your project, adjust the {file}`Dockerfile` by inserting the command `COPY zope.ini etc/` before the `RUN` command as highlighted below.
This new command copies the {file}`zope.ini` file into the container.

```{code-block} dockerfile
:emphasize-lines: 4
# Add local code
COPY scripts/ scripts/
COPY . src
COPY zope.ini etc/
# Install local requirements and pre-compile mo files
RUN <<EOT
```

After making these changes, build the project container as usual.
It will no longer output the access log, but will continue to output the event log.

0 comments on commit f9f1716

Please sign in to comment.