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

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

Define the delivery actions

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

You can use Buddy parameters 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:

  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)
  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
  4. WARNING: 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!

  5. 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
    

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!