Skip to content

Commit dce3042

Browse files
authored
Merge pull request plone#1359 from plone/zopeconfd
Add documentation for feature in plone#92
2 parents 3cf75b7 + f43f924 commit dce3042

File tree

1 file changed

+87
-20
lines changed

1 file changed

+87
-20
lines changed

docs/install/containers/images/backend.md

Lines changed: 87 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -224,38 +224,53 @@ services:
224224

225225
These variables are used to configure [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
226226

227+
(containers-images-backend-add-ons-label)=
227228

228-
### Add-on variables
229-
230-
| Environment variable | Description | Details |
231-
| --- | --- | --- |
232-
| `ADDONS` | A space separated list of python libraries to install | {ref}`containers-images-backend-add-ons-label` |
233-
| `DEVELOP` | A space separated list of python libraries to install in editable mode | {ref}`containers-images-backend-developing-packages-label` |
234-
| `PIP_PARAMS` | Parameters used in `pip` installation commands | [`pip install`](https://pip.pypa.io/en/stable/cli/pip_install/) |
235-
229+
### Add-ons
236230

237-
(containers-images-backend-add-ons-label)=
231+
It is possible to include add-ons during startup time in a container created using this image.
238232

239-
#### Add-ons
233+
```{warning}
234+
We advise against using this feature on production environments — the recommended method is to
235+
extend the official container images to include your desired add-ons in your own container.
236+
This has several advantages, among which is the certainty that your container will always
237+
run the exact add-on code you built into it.
238+
```
240239

241-
It is possible to install add-ons during startup time in a container created using this image.
242-
To do so, pass the `ADDONS` environment variable with a space separated list of requirements to be added to the image:
240+
To do so, pass the `ADDONS` environment variable with a space separated list of requirements to be added to the image
241+
(see below for documentation of the supported variables):
243242

244243
```shell
245244
docker run -p 8080:8080 -e ADDONS="pas.plugins.authomatic" plone/plone-backend:{PLONE_BACKEND_VERSION} start
246245
```
247246

247+
After Plone has started, you can add your Plone site (if none exists yet) and install the added
248+
add-ons to your site.
249+
248250
This approach also allows you to test Plone with a specific version of one of its core components
249251

250252
```shell
251253
docker run -p 8080:8080 -e ADDONS="plone.volto==3.1.0a3" plone/plone-backend:{PLONE_BACKEND_VERSION} start
252254
```
253255

254-
```{warning}
255-
We advise against using this feature on production environments.
256-
In this case, extend the image as explained before.
257-
```
256+
#### Add-on variables
258257

258+
| Environment variable | Description | Details |
259+
| --- | --- | --- |
260+
| `ADDONS` | A space separated list of python libraries to install | {ref}`containers-images-backend-add-ons-label` |
261+
| `DEVELOP` | A space separated list of python libraries to install in editable mode | {ref}`containers-images-backend-developing-packages-label` |
262+
| `PIP_PARAMS` | Parameters used in `pip` installation commands | [`pip install`](https://pip.pypa.io/en/stable/cli/pip_install/) |
263+
264+
#### Adding configuration to `zope.conf` or additional ZCML
265+
266+
Some Plone add-ons require changes to `zope.conf` or extra ZCML.
267+
268+
With the standard container, it is not possible to add configuration fragments to
269+
`zope.conf` directly or add extra ZCML, like it is with the `buildout` deployment
270+
method.
271+
272+
However, you can derive your own container image, and drop in configuration
273+
fragments. See {ref}`backend-extending-from-this-image-label` below for instructions.
259274

260275
(containers-images-backend-developing-packages-label)=
261276

@@ -265,6 +280,11 @@ It is possible to install local packages instead of packages from pip.
265280
To do so, pass the `DEVELOP` environment variable with a space separated list of paths to Python packages to be installed.
266281
These packages will be installed with `pip install --editable`.
267282

283+
```{warning}
284+
We advise against using this feature on production environments — the recommended method is to
285+
extend the official container images to include your desired add-ons in your own container.
286+
```
287+
268288
```shell
269289
docker run -p 8080:8080 -e DEVELOP="/app/src/mysite.policy" plone/plone-backend:{PLONE_BACKEND_VERSION} start
270290
```
@@ -275,10 +295,7 @@ This approach also allows you to develop local packages by using a volume.
275295
docker run -p 8080:8080 -e DEVELOP="/app/src/mysite.policy" -v /path/to/mysite.policy:/app/src/mysite.policy plone/plone-backend:{PLONE_BACKEND_VERSION} start
276296
```
277297

278-
```{warning}
279-
We advise against using this feature on production environments.
280-
```
281-
298+
(backend-extending-from-this-image-label)=
282299

283300
## Extending from this image
284301

@@ -304,6 +321,56 @@ And start a container.
304321
docker run -p 8080:8080 myproject:latest start
305322
```
306323

324+
### Changing default values of environment variables
325+
326+
All the environment variables documented above are supported in your
327+
derived container's Dockerfile. You can override the default values
328+
of variables as follows:
329+
330+
```Dockerfile
331+
# Add environment variables before any CMD or ENTRYPOINT stanzas,
332+
# and after any FROM, RUN and COPY stanzas.
333+
ENV ZODB_CACHE_SIZE="120000"
334+
```
335+
336+
Of course, you can always override these variables upon container
337+
start by using the Docker `docker run` argument `-e VAR=value`.
338+
339+
Be aware that some variables are not intended to be used in production.
340+
Check the respective variable documentation above to determine whether
341+
you should use it, or use a different method to get the desired result
342+
in production.
343+
344+
### Adding `zope.conf` configuration fragments
345+
346+
In the directory containing your `Dockerfile`, create a folder `etc/zope.conf.d`.
347+
Add your `zope.conf` configuration fragments there.
348+
349+
Now add the following to your `Dockerfile`, before any `CMD` or `ENTRYPOINT`
350+
stanzas it may have, and after the `FROM` and any `RUN` stanzas:
351+
352+
```Dockerfile
353+
COPY /etc/zope.conf.d/*.conf /app/etc/zope.conf.d/
354+
```
355+
356+
This ensures your fragments are deployed in the `zope.conf.d` folder, which then
357+
will be used to amend the `zope.conf` file prior to starting Plone.
358+
359+
### Adding ZCML fragments
360+
361+
In the directory containing your `Dockerfile`, create a folder `etc/package-includes`.
362+
Add your ZCML configuration fragments (named `*-meta.zcml`, `*-configure.zcml`,
363+
`*-overrides.zcml`) as files in that folder.
364+
365+
Now add the following to your `Dockerfile`, before any `CMD` or `ENTRYPOINT`
366+
stanzas it may have, and after the `FROM` and any `RUN` stanzas:
367+
368+
```Dockerfile
369+
COPY /etc/package-includes/*.zcml /app/etc/package-includes/
370+
```
371+
372+
Your ZCML fragments will be copied into the container and automatically included
373+
when Plone starts.
307374

308375
## Advanced usage
309376

0 commit comments

Comments
 (0)