WordPress in Docker. Part 2: Automation

Last updated January 7, 2019

WordPress in Docker. Part 2: Automation

In the first part of the guide we showed you how to Dockerize your WordPress project and run it on the server using Docker Compose. This article we'll tell you how to streamline the whole process down to a single push to Git repository.

Set up a project with Buddy

First you need to hook up your repository with Buddy:

  1. Sign up to Buddy with your GitHub/Bitbucket account or email
  2. Create a new project, select your Git provider, and choose your WP project:

For the purpose of this guide we'll use a Git repository with an existing WP theme: https://github.com/buddy-works/buddy-wp-theme.git

Attaching a repositoryAttaching a repository

Set up a delivery pipeline

Now you need to configure a delivery pipeline so that it automatically executes on every push to branch:

  1. Click Add a new pipeline
  2. Set the trigger mode to On every push
  3. Select the branch that will trigger the execution
  4. Click Add a new pipeline when ready: Adding a new pipelineAdding a new pipeline

Define the delivery actions

Now it's time to reproduce your workflow into actions:

You can use environment variables to tag your images in the registry, for example ${execution.to_revision.short_revision}.

  1. (Optional) Add a build action to process your files before the deployment. In this example we'll use Gulp to test the application: Build Action Example PipelineBuild Action Example Pipeline

  2. Add the Docker build action and configure the details:
    • select the Dockerfile from the repository
    • select the registry to which Buddy will push your image (eg. Docker Hub) Configuring the detailsConfiguring the details
  3. Add the SFTP transfer action to upload docker-compose to the server:
    • provide authentication details to your server
    • select upload from the repository
    • set the source path to the directory with docker-compose: Adding the SFTP actionAdding the SFTP action

If you're using our example repository make sure to edit the docker-compose file and enter the credentials to your Docker registry or Buddy will not be able to connect and pull the image!

Editing Docker ComposeEditing Docker Compose

  1. Add the SSH action to pull and run your Docker image on the server:

    • provide authentication details to your server
    • in the SSH commands field enter:

     docker-compose down
     docker-compose up -d

    Adding the SSH actionAdding the SSH action

Run the pipeline

Congratulations! You have successfully configured the delivery pipeline. Make a push to the repository and watch Buddy automatically Dockerize your project and run it on the server:

Awesome, isn't it?

In the last part of the series we'll show you how to run your project on a Kubernetes using Docker, which is especially useful if you seek high availability and scale for your apps. Stay tuned!


About the Author
Alexander Kus

Alexander Kus

Customer Success Manager

A story-teller and conversation-lover, Alexander decided to invest his skills to help his friends at Buddy transform the cold language of patch notes into exciting narratives. Also: an avid gamer, hip-hop DJ, Liverpool FC fan, absentminded husband, and the father of two.

Buddy Makes Developers Happier

You use lots of tools to get web & app development done. Buddy creates more time in your day by helping you automate those tools.

Sign up for free with