WordPress Release Candidate Builds in Docker

The first WordPress 5.4 release candidate was just published this week. The official WordPress Docker images are only published for release builds, so you can’t test any RC builds from there (for example on the Tags tab you won’t find 5.4-RC1 anywhere). However, it’s pretty straightforward to build the RC build yourself locally following these steps.

Build Docker Image Locally

The first step is to make a local clone of docker-library/wordpress (the official Docker image source tree for WordPress).

Next we need to figure out what the SHA1 checksum is for the release candidate we’re going to use:

  1. Visit the Releases page to understand the download link format
  2. Find and copy the URL for one of the sha1 files for the tar.gz download (in this case the latest is https://wordpress.org/wordpress-5.3.2.tar.gz.sha1)
  3. Substitute in the RC version and view the link to copy the SHA1 value (in this case we have https://wordpress.org/wordpress-5.4-RC1.tar.gz.sha1) which returns 7cd079f329b1e9cc1c8148543081ae38301530e3

Now you can edit the appropriate Dockerfile to refer to the RC release. The WordPress Docker tree currently has 3 different PHP versions and 4 different package types for a total of 12 options. In my case I’m using PHP 7.3 and Apache, so I’ll edit the file php7.3/apache/Dockerfile. Towards the bottom of that file you’ll see environment variables for WORDPRESS_VERSION and WORDPRESS_SHA1. Both of these need to be updated using the value from above:

ENV WORDPRESS_VERSION 5.4-RC1
ENV WORDPRESS_SHA1 7cd079f329b1e9cc1c8148543081ae38301530e3

Now we can build the specific Docker image locally and tag it. Again using my example of PHP 7.3 + Apache, the build command will be:

docker build ./php7.3/apache/ -t wordpress:5.4-RC1-php7.3-apache

On my old MacBook Pro this takes about 4 minutes. Assuming the build ran correctly, docker images wordpress should show the result:

REPOSITORY          TAG                     IMAGE ID            CREATED             SIZE
wordpress           5.4-RC1-php7.3-apache   ca70b87fabb4        14 seconds ago      548MB
wordpress           5.3.2-php7.3-apache     a9f43b7c47db        2 months ago        539MB

Docker Compose with MySQL Database

Finally, we can refer to that local RC1 image using Docker compose. Follow the instructions in Compose and WordPress Quickstart but don’t build the project just yet.

In the docker-compose.yml file, change the WordPress image line from image: wordpress:latest to image: wordpress:5.4-RC1-php7.3-apache.

Now you can continue the instructions by building the project docker-compose up -d. In a few minutes you should now have a running WordPress release candidate!

Notes

  • I’ve used the same technique with my new WordPress workflow and it worked really well. Also 5.4-RC1 didn’t exhibit any problems, but that’s what I expected considering my use case and plugin collection is pretty simple.
  • Subscribe to WordPress News if you’d like to be notified of all release candidate and normal updates. For normal releases, it can take a couple days for the official Docker images to be updated.
Posted in: Web