With a little customisation, you can easily extend the base plone.docker image with custom addon code. This is a demo of how it might be used.
Note: This addon doesn't do much and is mostly to demonstrate common ways of using the plone.docker image with a Plone addon. The example image uses a public docker registry stored at docker hub. Depending on your usecase you may need to set up a private docker registry.
You have plonecli installed.
For your own addon you will need to replace example.dockerizedploneaddon
with
the name of your addon.
plonecli create addon example.dockerizedploneaddon
As the developer of an addon you may choose not to use docker for day to day use. Use plonecli to build and server your addon
cd example.dockerizedploneaddon plonecli build --clean plonecli serve
OR without plonecli run the following commands:
virtualenv . -p python2.7 --clear ./bin/pip install -r requirements.txt --upgrade ./bin/buildout -n
To make it easier for others to try out your addon you can "dockerize" and distribute it.
Do this by adding a docker.cfg
file and a Dockerfile
to your addon folder
Contents of docker.cfg (customise the eggs
and develop
entry to match the name of your addon):
[buildout] extends = buildout.cfg eggs += example.dockerizedploneaddon user=admin:admin develop = src/example.dockerizedploneaddon [versions] # plone.api = 1.5.1 [instance_base] resources = ${buildout:directory}/resources
Contents of Dockerfile (customise the second COPY command to match the name of your addon):
FROM plone:5 COPY docker.cfg /plone/instance/ COPY --chown=plone:plone . /plone/instance/src/example.dockerizedploneaddon RUN gosu plone buildout -c docker.cfg
Once you have those two files, run docker build .
Here are some "shortcut" commands for building and launching a container
cd example.dockerizedploneaddon imageid=$(docker build .) container=$(docker run -d -p 8080:8080 $imageid)
You can stop the container with the following command:
docker stop $container
Once you're confident that your addon has been configured properly for Docker, you can register it with a container registry. Below are the steps for doing so with docker hub. Register your repository with docker hub and connect it to your repository github or bitbucket so that it automatically builds new images every time you make changes.
Use the docker version to help your team use and test your addon quickly.
Once your addon has been dockerized you can quickly launch it on any machine that has docker.
docker run -it -p 8080:8080 alteroo/example.dockerizedploneaddon
We've provided a data tarball.
wget https://github.com/alteroo/example.dockerizedploneaddon/releases/download/v00data/data.tar.gz tar xf data.tar.gz setfacl -R -m u:500:rwX data docker run -it -v $(pwd)/data:/data -p 8080:8080 alteroo/example.dockerizedploneaddon
When you visit localhost:8080/Plone
you should see a slightly customised Plone site:
Generally, your data tarball should ONLY contain a blobstorage
folder and
a filestorage
folder with a single Data.fs. In a standard buildout directory, the data files and folders
are typically located under the var
directory. Our docker image stores the same data files and folders
under the /data
directory of the container.
├── blobstorage │ └── tmp ├── filestorage │ ├── Data.fs │ ├── Data.fs.index (remove) │ ├── Data.fs.lock (remove) │ └── Data.fs.tmp (remove) ├── instance │ └── import └── log (optional) ├── instance.log └── instance-Z2.log
- Move the blobstorage and filestorage folder into a data folder
- Be sure to remove the extra index, lock and tmp files (Data.fs.index, Data.fs.lock, Data.fs.tmp)
Your data folder should have this structure:
data ├── blobstorage │ └── tmp └── filestorage └── Data.fs