Description
I am currently attempting to promote my image including custom theme to Production using a custom Dockerfile, like so:
FROM wordpress:latest
COPY wp-content/ /usr/src/wordpress/wp-content
The resulting image will have the wp-content directory in the "distribution" directory, which is copied to /var/www/html on initialisation when the right conditions are met.
The right conditions being that the following files do not exist in /var/www/html:
- index.php
- wp-includes/version.php
The first time, this works as expected as the target volume mounted on /var/www/html will be empty still. However, any subsequent updates will detect that /var/www/html has content in it and therefore initialisation will be skipped. With it, any changes made to my custom theme are not applied.
The simplest solution would be to not map a volume on /var/www/html, so that initialisation takes place every time - as each startup would effectively end up with an empty directory. However, the downside of this is that I end up with tons of dangling volumes, as the provided Wordpress image has a VOLUME directive set for this directory, which results in Docker creating an unnamed Volume to map on the directory. This is the approach I'm currently taking, together with a cleanup script running on the hosts to remove the volumes.
This is obviously less than ideal. Why is /var/www/html a Volume in the first place? Considering that in a local development environment the necessary content is bind mounted and in a production image the data is copied to /usr/src/wordpress.