I'm building a Wordpress CI/CD pipeline based on Docker and some custom deployment scripts. The flow is pretty standard:
- Dev machine pushes complete website archive and database dump to external repository
- There is similar Wordpress docker infrastructure (web, db, app) being used on dev machine and on production servers
- When deployment is initiated the production machine downloads code and db to local repository and spins a new Docker out of it
It all works great, but the problem I'm facing is that Wordpress by default includes full URL in edited pages. So if developer is adding an image to a page the database page will have a code
<img src="sampledevmachine.local/image1.jpg">
Now there are two solutions that come to it. Either the deployment script does search and replace on the database dump file or developer machines can have their hosts file adjusted to make Wordpress think its being accessed by production domain.
Both of these solutions sound a little "dirty". So I'm curious how others would approach such a problem and how would you setup an "elegant" CI/CD for Wordpress.