Ask HN: How to handle content of a flat-file CMS in Docker images?
Hi HN Community,
I currently work on a project that runs with Kirby, a flat file CMS. Means: all content is saved in files inside the project structure. The project should be built as a Docker image and deployed to the server afterwards.
I would like to know how a good solution could look like that handles the changing content files inside the Docker containers?
Current evaluated solutions:
- save them in shared folders outside of the Docker containers, via volumes.
- handle them via Git and store them in a submodule, changes are commited with the Autogit Kirby plugin.
What are your thoughts? :)
(
9 comments
| 2 points
| on HN
)
For prod, if you are trying to keep runtime simple, I would bake the content into the Docker containers and keep the containers immutable as others have suggested. This works especially well if you're deploying on a FaaS platform like Zeit Now. Baking the content into the image makes scaling effortless if you need it.
For local dev, I would just use a docker volume or bind mount.
So more likely solution 2, the important thing is that you regenerate the container image every time you deploy changes. If you care about faster builds, keep the cmd to pull content towards the end of your Dockerfile.
Immutable containers can be relaunched even when your data is not available, and new images can’t be built. It’s rare, for sure, but even s3 goes down.
Edit: of course for development it’s easier to mount a volume.
And get gitlab-ci to redeploy it automatically to a kubernetes cluster each time it changes.
Keep in mind that development Docker and production Docker are two different worlds. There are things which Docker brings to the table in both worlds and the way you use it is different in both. It's quite possible that it's really helpful for development but not yet needed for production.
In your case, you would probably be better off outsourcing the plumbing of your hosting to a service such as Netlify or Heroku.
If you still have questions, a better place to check would be one of the StackExchange sites. Post your question there or find a similar question which has already been answered.
Shared volumes are good for development though.