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:
Sign up to Buddy with your GitHub/Bitbucket account or email
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 repository
Set up a delivery pipeline
Now you need to configure a delivery pipeline so that it automatically executes on every push to branch:
Click Add a new pipeline
Set the trigger mode to On every push
Select the branch that will trigger the execution
Click Add a new pipeline when ready:
Adding 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}
.
- (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 Pipeline
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 details
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 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 Compose
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 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!