Enterwell icon
Vedran Blazenka

WWDW Part III : Rocketeer task runner

Previously on WWDW

We have set up a brand new Ubuntu 14.04 server, configured it and added a new site to it. Now we have to configure a local working enviroment. At Enterwell, we are using Windows machines (most of the time 😀 ) so we created a useful and simple workflow for WordPress projects. You can see more details about our workflow in the next blog post. In this blog post I’ll explain what is Rocketeer, how to install and configure it and how it can help WordPress devlopment process.

About Rocketeer

Rocketeer is a PHP task runner and deployment package. You can read more about it here. To sum up, Rocketeer makes PHP deployment easy, and using Rocketeer tasks you can customize the deployment process. Using rocketeer to deploy your application is done by single terminal command, and you can easily revert to older versions of your site (no more this 😀 ).

Rocketeer file structure

Rocketeer has a very neat folder structure for your project. It creates folders for your stages and releases. Folder structure is shown in the next picture

rocketeer-structure (1)

In the root folder of your site (testsite.net) you have folders for each of your stages (by default there are test stage – for testing, and prod stage – for production). When you execute a default deploy command it will deploy the site to the test stage. New release of your site is deployed in releases folder of the selected stage, and the folder name is date and time of deploy. By default Rocketeer keeps last 5 releases. When deploy is finished Rocketeer updates symlink current in the stage folder. This symlink (folder) is how you access the latest version of your site. All files and folders that are shared between versions of app (things that doesn’t change like wp-config.php, .htacces or uploads folder) are saved in the shared folder. Shared files (and folders) are defined remote.php of Rocketeerconfig. Details about how sharing works and why are explained in the next blog post.

Requirements

Server requirements

Rocketeer can only be used for deployments to the enviroments that have SSH capabilities (VPS, virtual machines, etc.). So you cannot use it if you only have FTP access to your server (for example shared hostings).

You need to have PHP, composer and Git installed (if you did everything like in this blog post you have nothing to worry about).

Local requirements

You need to have PHP installed (XAMPP package on Windows installes everything you need for WordPress development). After PHP install composer (as explained here).

Install WordPress (famous 5 minute install) into your site folder ( folder xampp\htdocs\{sitename}).

You’ll have to have a Git repository for your project (site) because Rocketeer uses Git to download the latest version of the project code to a server)

Installation

Rocketeer is installed easily by running a few commands from command prompt (my advice is to install cygwin, or some similar tool so you can do simple linux commands in Windows command prompt). You’ll need to position to your site folder and run these commands

composer require anahkiasen/rocketeer

This command will install rocketeer into your working directory (site folder). You’ll see that it created a vendor directory where Rocketeer is installed and a .rocketeer directory where the local config is stored. In order to use it by simply calling “rocketeer” from command prompt run the following command

echo @php "%~dp0vendor\anahkiasen\rocketeer\bin\rocketeer" %*>rocketeer.bat

You have installed Rocketeer and you just need to configure it to start deployment.

Configuration

All files for Rocketeer configuration are stored in the .rocketeer folder. Your Git credentials, as well as passwords for SSH access to the server are stored in these files so you should not share this folder with anyone or anyhow upload it to the Internet. File structure is shown in the next image

rocketeer-config

You can manually change every file and add your custom config or you can use this command to configure Rocketeer using the command prompt.

rocketeer ignite

After that, Rocketeer will ask you about your configuration:

  • default connection – default connection name (in most cases name of your site)
  • connection – new connection name (as this is the first connection, set it to same value as default connection)
  • host – your server’s host (IP address or URL of your server)
  • username – SSH username for your user (user must be set up with permissions as explained here)
  • password or SSH key
  • application name – name of your application, should be the same as sitename name of your site on the server ( /var/www/{sitename} ) because this tells Rocketeer where to deploy your application
  • repository – URL to project repository on Git (https://{username}@{git_server}/{path_to_repo}/{repo}.git)
  • username – your Git repo username
  • password – your Git repo password

After this, you can check Rocketeer configuration by running the following command

rocketeer check

Note
For some strange reason, after you’ve done ignite command Rocketeer will ask you to repeat the connection details. Do so. Again, enter exactly the same data as before for connection, host, username and password.

Rocketeer tasks

Tasks are an important concept in Rocketeer. Rocketeer comes with many predefined tasks (deploy is a Deploy task), and rocketeer enables you to write you own tasks. You can register tasks to run on specific events (after deploy for example), or you can run tasks directly from the command prompt. Deployment of a new site to production (if rocketeer is configured properly) is simply done with following command

rocketeer deploy

More about tasks generally can be found here, and more about our custom tasks that support our WordPress workflow can be found in our next blog post.

What next?

Our workflow based on Rocketeer (and  our tasks) is descirbed in our next blog post : WordPress Windows Development Workflow : Enterwell’s way to do it. After reading that you’ll be able to make WordPress deployments easily, to sync your database local database with remote server’s database, and to sync wp-content from remote server (plugins, themes and uploads) with your local wp-content (in development environment).

Info

This blog post is a part of Windows WordPress Development Workflow (WWDW) blog posts’ series. All blog posts in the series are:

  1. WWDW Part I : Server Configuration
  2. WWDW Part II : Create A New Site
  3. WWDW Part III : Rocketeer
  4. WWDW Part IV : Enterwell’s way

 

Share on FacebookTweet about this on TwitterShare on LinkedInShare on RedditEmail this to someone