Scaling horizontally with containers

Has anyone tried hosting Grav using containers like Docker? How does one scale the application? Can I host n number of Grav container hosted nodes reading from the same persistent disk? How does the administration of content work in such a hosted environment? I’ve been using the admin plugin for editing content, but when it comes to creating plugins/themes, you still have to write to the persistent disk manually or using the devtools CLI to bootstrap a plugin project. How does this work if the Grav application is hosted in several container nodes?

There are several Grav docker images available. I would imagine you could host several on the same disk without much impact on resources, unless they all try to cache many and large images at once (which in itself is a dangerous process even with a single install).

You would in this instance, with multiple host-configurations, get a Grav-installation on each both port or domain with their corresponding /admin.

I wonder if it might not be better to limit the hosted nodes by grouping them together under common versions. Ie. site A, B, C is hosted on Node 1 with Grav v1.1.1, site D, E, F hosted on Node 2 with Grav v.1.1.2, etc. Thus you reduce files (content, themes, plugins, configs) to bare minimums matching a package-dependency structure, and consequently reduce bugs from differences in versions.

I’m sure someone with more experience with Docker could add some insight though.

Dear @doos, I using Docker for development. In your case I suggest creating Docker containers with a fixed Grav version (as @OleVik already pointed out) and expose the Grav specific user folder (and maybe sub-folders, too) as a volume, because it gives you the biggest freedom. From there you can link your image to a “shared” user folder or even to a sub-folder with same or different pages, plugins and themes folders and so on. Managing can be done either on your different sites for a specific install or via a “master” Grav instance, which has access to all pages folders.

It just depends on your choice :slight_smile: If you want it lightweight and fast, use PHP 7 + Nginx with Alpine.