I’ve seen articles that teach how to migrate WordPress into Docker containers (see also here). I want to do the opposite. I am already running WordPress locally via Docker on my Windows 10 laptop. I want to migrate my local (containerized) WordPress instance into a hosted provider (e.g. WP Engine, GoDaddy, Bluehost, etc.). I don’t think these hosting providers offer containerized WordPress hosting, and even if they did – it likely is more expensive than their traditional infrastructure.
I also like the idea of pushing updates (plugin and theme changes or additions) to my hosting provider via git, like I see described in this WP Engine Git Setup article.
I’d like advice or instructions for this. I am passable with my Docker skills, but I am new to WordPress. The most important things I need to understand:
- How do I preserve articles I’ve written and published on my hosting provider, when I suddenly “git push” new updates to my hosting provider?
- How do I backup my database on my local computer, given that my containerized WordPress does not have phpMyAdmin included?
- How do I ensure that path names like “http://localhost:8000” that I use for local testing are properly replaced with the proper domain-name when I push?
- Need I be concerned with the
docker-entrypoint-initdb.d
folder? Where is the official documentation for this special folder? Are there other “magic” directories like this I should be aware of? - How might VersionPress fit into this story, if at all?
- Is there anything fundamentally flawed about what I am trying to achieve?
Ultimately I don’t need a “git push” deployment model. For example, I doubt GoDaddy or Bluehost will offer me the “git push” capability, but their hosting is also less expensive; I could accept an FTP deploy if it was not too burdensom. But whether I deploy with git or deploy with FTP, I still want the ability to run my development effort within Docker, and version locally with git.
Also, I am not actually developing brand new WordPress themes or plugins. I am simply using my local WordPress container to add and test pre-existing themes and plugins.
Background
I am using the docker-compose file shown below. It will only work if you change “Docker for Windows” Settings->Shared Drives…so that a Windows drive (the “C” drive in my case) is shared. Here is the docker-compose file:
version: '3.2'
services:
db:
image: mysql:5.7
volumes:
- type: volume
source: wp_db
target: /var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- .:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
wp_db:
driver_opts:
type: none
device: ./wp-db
o: bind
The above allows (I think) all of the WordPress themes and plugins (along with DB modifications) to be exposed on my file system, outside of the WordPress container. I can then capture these files into git. My plan is to use the WordPress .gitignore
file suggested by Github, or perhaps one of the .gitignore
files described in the aforementioned WP Engine article.