Plone 5.1 Docker container packing schedule

Is database packing scheduled in the Plone 5.1 Docker container? I logged onto the container, and it looks like crontab is empty, so I'm wondering if I need to add this...

Which container? Where is the Dockerfile and where is the related buildout configuration?

Usually Docker containers are single threaded runners and not an full operating system with cron.

Chaperone is a good tool to realize cron like tasks within a Docker container.
I used it for different tasks, but not for database packing. I usually use history free RelStorage and rarely pack (it only removes deleted objects).

Unfortunately Chaperone seems dead (latest release 2016) and we had a lot of issues with it in production, thus we removed it from most of our containers.

If you use Rancher to orchestrate your deployments, container-crontab is a good option. Also Kubernetes CronJob may help. Otherwise you can just add cron job on your server (or within a dind container) that will run the packing command:

$ docker run -d -v zeo-data:/data --name=zeo plone zeo
$ docker run -it --link=zeo --name=plone -e ZEO_ADDRESS=zeo:8080 -p 8080:8080 plone fg

$ crontab -e
# Pack daily at midnight
0 0 * * * docker run -it --link=zeo -e ZEO_ADDRESS=zeo:8080 plone bin/zeopack
2 Likes

The container is the official Plone container on Docker Hub, so the Dockerfile is here and the buildout configuration is here. I know I had talked about customizing that in the past, but we never finished it.

Thank you for the suggestions! Do you know whether either container-crontab or Chaperone are installed by default on the official 5.1.5 image?

Nope, the above are external solutions, depending on your orchestration tool. As @jensens already mentioned with Docker the best practice is to have only one process/application running per container, that's the whole idea of Docker.

No.

As a simple solution starting a Plone container with cron in foreground should work using CMD [ "cron", "-f" ].

Also, you could modify the entrypoint

to support zodbpack, so it can be run direct.

Or modify the whole to run a configure and run a cron doing a zodbpack instead of the instance using a different command.

Latter would be something useful for the official image in some way (details to be discussed).

1 Like

One old idea is to use the Zope Clock Server for asynchronous tasks. I'm not fully convinced of this being a good idea, but it would circumvent the main issue of containerization.

The correct way to do this would be to roll a clockserver container so you have a ZEO client which only does that for you.

https://docs.plone.org/develop/plone/misc/asyncronoustasks.html

Exactly what I needed to know. Thanks.