So one of the things I want to do during my between-jobs downtime is practice my coding. And in particular, since I thought it’d be nice to a) start small and b) play with something I’m actually interested in coding (as opposed to, say, just focusing on random interview-type questions which will eventually bore me to tears), I decided I’d try to play with making a small WordPress plugin.
I’ve already done one that I’m running locally on Annathepiper.org: namely, to show y’all my archive of roleplay logs. Eventually I want to do a newer version of that, something that might let me actually practice setting up a simple web service.
For now though I’m going to do something less complicated. There’s a very old plugin called “lj-tag-parser”. This thing has a very simple job: allowing the LJ-style syntax for usernames and communities in your WordPress posts and comments. I’m using it right here on annathepiper.org, which is why you can actually see LJ-style usernames and tags if I write something like, say,
However, this thing hasn’t been updated in ages. And I thought it’d be nice to expand it to allow Dreamwidth-style syntax in addition to LJ-style, and possibly also allow generation of such tags via shortcodes.
But before I do all of that, I wanted to make sure I could set up a clean WordPress dev install.
In the past, when I’ve played around with dev-type WordPress stuff, I just did this on a separate blog on my annathepiper.org network. But coming at this with my SDET hat on, I thought it’d be cleaner and more appropriate to developing my coding experience if I set it up the way I’d do it in a work environment.
Which means a brand new, clean WordPress dev install. And in particular, using official WordPress and MySQL images from Docker.
For those of you who aren’t in the tech industry, suffice to say that Docker is a tool that lets you do exactly this kind of thing. You can set up a thing you want to play with in its own little container on your system, without having to worry about it interfering with anything else you might be doing. Docker lets you go about this in a few different ways. You can go get official images for things (like, say, the latest WordPress install) and do a single run using that image.
Or, if you want to do something a bit more complicated (like, say, running the official WordPress image AND a MySQL image that you’ll need to actually power the WordPress install), you can chain them together using a thing called Docker Compose.
Docker Compose works by you setting up all the config data you need in a file called docker-compose.yml. I’m still fairly new to the syntax this thing requires, but fortunately, I learned a bit about it while I was still at my previous day job at Big Fish. So I was able to utilize that knowledge to build a file that’d let me set up that clean WordPress dev install I want.
I did have to jump through a few hoops to get all the info I needed, though. Here are some pages that proved useful:
- Local WordPress Development with Docker: 3 Easy Steps on Medium (for initial tips on what images I needed, as well as a handy note in the comments re: adding PHPMyAdmin)
- WordPress Dockered Environment on Github (where I looked at that user’s example docker-compose.yml)
- docker-compose wordpress mysql connection refused on Stack Overflow, to solve an issue I was seeing in my Compose logs
- How Do I Set Hostname in Docker Compose?, also on Stack Overflow, to see what settings I needed to allow for a friendly hostname, vs. just having to say “localhost” in my dev URL
- Install WordPress with Docker Compose on Linode.com, which helped me solve an issue with the dev site not properly loading its assets
So now, as of this writing, I have a nice little set of Docker containers running on my dev box on Linux. And the nice thing about doing this via Docker, especially, is that I could take this exact same docker-compose.yml, reboot my box into Windows, and use it there too. All I need to be running locally is Docker and Docker Compose. The rest of it comes in with the images I specify!
And for the interested, I have checked in my final docker-compose.yml up on my personal Github account, and you can see it right here.
Mirrored from annathepiper.org.