The Second Coolest Thing: A New API for you (v1)


This weekend, I had some free time to work on something I’ve thought about for a while… an API to build and push a configurable WordPress Docker Image.

Right this moment, there are a couple new API endpoints alive on this blog:

  1. https://www.withinboredom.info/wp-json/docker/v1/file
  2. https://www.withinboredom.info/wp-json/docker/v1/build

/file will give you a Dockerfile, while /build will build and push you a new Docker image, configured just for you.

Using them, are simple. That’s the best part.

Simply POST to https://www.withinboredom.info/wp-json/docker/v1/build (you can also hit the /file endpoint to preview the Dockerfile) this JSON to recreate this blog’s configuration:

This will return a JSON response:

You’re not limited to WordPress.org, you can also give it urls or specify the specific version of a plugin to install. It will build your specific container for you and push it to Docker Hub. (Credentials are not stored, btw).

Handily, the request will block until this is complete (it’s not asynchronous). I did this on purpose, so you’d know when it was done without having to ask. Also, this is “kind of hack weekend” project, so I didn’t go all-out. I only had an hour or two a night.

With the new image and tag it returns to you, you can immediately pull and deploy anywhere.

This will likely be improved upon over time:

  1. Intercept plugin/theme/core installations and upgrades, and build a new image instead of installing a file
  2. Automatic deployment when running in Docker Swarm
  3. Docker Swarm control panel

These are the things that the WordPress platform can easily handle… I’ll be surprised if you don’t see them sooner than later.

Feel free to view the code (or contribute) on GitHub.

,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.