Skip to content

Commit f9f1716

Browse files
authored
Merge pull request #1874 from plone/erral-zopeini
Add documentation on how to customize containers with custom files
2 parents 96eed09 + c9cf548 commit f9f1716

File tree

2 files changed

+128
-3
lines changed

2 files changed

+128
-3
lines changed

docs/install/containers/index.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@ The Plone 6 container images are compliant with the [Open Container Initiative (
2020
They should work with any OCI-compliant container engine for developing, managing, and running Plone 6 images.
2121
Two popular options include [podman](https://podman.io/) and [Docker](https://www.docker.com/products/docker-desktop/).
2222

23-
The community provides official images that could be used for standalone Plone installations.
23+
## Resources
24+
25+
The community provides {doc}`images/index` that you can use for standalone Plone installations.
2426
These images support a variety of installation options.
25-
You can choose from Classic UI or the new frontend, or specialized databases using ZEO or a relational database.
27+
You can choose from Volto or Classic UI for a frontend, or specialized databases using ZEO or a relational database.
28+
29+
The {doc}`examples/index` and {doc}`recipes/index` provide configuration for proxy servers, load balancers, and caching services.
2630

2731
```{toctree}
2832
:maxdepth: 2
29-
:hidden: true
33+
:hidden:
3034
3135
images/index
3236
examples/index
37+
recipes/index
3338
```
3439

3540
## Getting started
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "Plone 6 Docker image recipes"
5+
"property=og:description": "Plone 6 Docker image recipes"
6+
"property=og:title": "Plone 6 image recipes"
7+
"keywords": "Plone 6, install, installation, Docker, containers, official images"
8+
---
9+
10+
# Docker recipes
11+
12+
This chapter offers some useful recipes when working with Plone containers.
13+
14+
15+
## Remove access log from Plone containers
16+
17+
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.
18+
19+
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.
20+
In such cases, you may have a Docker Compose setup with several components including a proxy server that already provides access logs.
21+
Instead of duplicating the logging output, it is common to remove the access logging from the Plone container.
22+
23+
To do so, create a custom {file}`zope.ini` file in your project's {file}`backend` folder with the following content.
24+
25+
```{code-block} ini
26+
:emphasize-lines: 17-20
27+
28+
[app:zope]
29+
use = egg:Zope#main
30+
zope_conf = %(here)s/%(config_file)s
31+
32+
[server:main]
33+
use = egg:waitress#main
34+
host = 0.0.0.0
35+
port = 8080
36+
threads = 2
37+
clear_untrusted_proxy_headers = false
38+
max_request_body_size = 1073741824
39+
40+
[filter:translogger]
41+
use = egg:Paste#translogger
42+
setup_console_handler = False
43+
44+
[pipeline:main]
45+
pipeline =
46+
egg:Zope#httpexceptions
47+
zope
48+
49+
[loggers]
50+
keys = root, waitress.queue, waitress, wsgi
51+
52+
[handlers]
53+
keys = accesslog, eventlog
54+
55+
[formatters]
56+
keys = generic, message
57+
58+
[formatter_generic]
59+
format = %(asctime)s %(levelname)s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
60+
datefmt = %Y-%m-%d %H:%M:%S
61+
62+
[formatter_message]
63+
format = %(message)s
64+
65+
[logger_root]
66+
level = INFO
67+
handlers = eventlog
68+
69+
[logger_waitress.queue]
70+
level = INFO
71+
handlers = eventlog
72+
qualname = waitress.queue
73+
propagate = 0
74+
75+
[logger_waitress]
76+
level = INFO
77+
handlers = eventlog
78+
qualname = waitress
79+
propagate = 0
80+
81+
[logger_wsgi]
82+
level = WARN
83+
handlers = accesslog
84+
qualname = wsgi
85+
propagate = 0
86+
87+
[handler_accesslog]
88+
class = StreamHandler
89+
args = (sys.stdout,)
90+
level = INFO
91+
formatter = message
92+
93+
[handler_eventlog]
94+
class = StreamHandler
95+
args = (sys.stderr,)
96+
level = INFO
97+
formatter = generic
98+
```
99+
100+
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.
101+
This [`translogger` middleware produces logs in the Apache Combined Log Format](https://docs.pylonsproject.org/projects/waitress/en/latest/logging.html).
102+
The above configuration removes it from the setup.
103+
104+
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.
105+
This new command copies the {file}`zope.ini` file into the container.
106+
107+
```{code-block} dockerfile
108+
:emphasize-lines: 4
109+
110+
# Add local code
111+
COPY scripts/ scripts/
112+
COPY . src
113+
COPY zope.ini etc/
114+
115+
# Install local requirements and pre-compile mo files
116+
RUN <<EOT
117+
```
118+
119+
After making these changes, build the project container as usual.
120+
It will no longer output the access log, but will continue to output the event log.

0 commit comments

Comments
 (0)