2017 © Pedro Pelรกez
 

craft-plugin craft-boost

A Craft plugin that provides basic deployment.

image

imarc/craft-boost

A Craft plugin that provides basic deployment.

  • Monday, April 30, 2018
  • by jeffturcotte
  • Repository
  • 20 Watchers
  • 9 Stars
  • 894 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 19 Versions
  • 14 % Grown

The README.md

README

Boost is a Craft plugin that enables a very simplified deployment system based on our typical process. While this software is functional, it should be treated as beta at best. It has strict requirements on how Craft is configured as well as the server environment., (*1)

Boost is designed to work with three environments โ€“ dev, stage, and prod. It automates copying assets and databases between evironments as well as pulling fresh code from a git repository., (*2)

  • The database and assets are always copied from the current canonical environment (either dev or prod.)
  • When deploying to dev or stage, the most recent commit from Git is used for VCS files.
  • When deploying to prod, the current commit on stage is used for VCS files.

For more information, see the iMarc Handbook., (*3)

Boost can, (*4)

  • Copy files from one Craft environment to another Craft environment on the same server,
  • Copy Craft's database from one environment to another, and
  • Pull new files from Git.

Boost does not support, (*5)

  • Migrations - including database migrations. All Database/Craft changes need to be made to the canonical environment only (dev initially, and prod once any content is put in prod.)

Craft Configuration

First, you must be using per environment configuration settings. While it should be possible to use Craft's built-in, domain-based environments, we have only tested using Boost with custom code like this:, (*6)

/* craft/config/general.php */

$env = preg_replace('#^.*/#', '', dirname(CRAFT_BASE_PATH));

$config = [
        'omitScriptNameInUrls' => true,
        'maxUploadFileSize' => 104857600
];

switch ($env) {
        case 'dev':
                $config = array_merge($config, [
                        'siteUrl' => 'http://dev.example.com',
                        'devMode' => true,
                        'useCompressedJs' => false,
                ]);
                break;
        case 'stage':
                $config = array_merge($config, [
                        'siteUrl' => 'http://stage.example.com',
                        'useCompressedJs' => false,
                ]);
                break;
        case 'prod':
                $config = array_merge($config, [
                        'siteUrl' => 'http://www.example.com',
                ]);
                break;
        default:
                die("Unfortunately, the server is misconfigured. Please review the configuration in config/general.php.");
}

return $config;

The benefit here is that environment is determined solely off of CRAFT_BASE_PATH, which avoids issues with domain aliases. Both craft/config/general.php and craft/config/db.php need to be setup like this., (*7)

Keep Assets Relative

Second, if you want to avoid needing to reconfigure Craft after every deployment, you should use relative paths when defining Asset Sources. For example, you might use '../public/writable/documents' instead of '/var/www/example.com/prod/public/writable/documents'., (*8)

Installing and Configuring Boost

Installing Boost is straight forward:, (*9)

  1. Put the plugin in craft/plugins/boost/.
  2. Through Craft's admin panel, install the plugin.
  3. Click on 'Boost', the now-hyperlinked name for the plugin to get to Boost's settings.
  4. Fill out the settings.

Composer, NPM, and Gulp

If a composer.json, package.json, or gulpfile.js are found in the new environment, then composer install --ignore-platform-reqs, npm install --production, and gulp will be called respectively. For these files to exist in the new environment, you will need to add them to the VCS Direcories setting below. If you do not add them, then these command won't be automatically called., (*10)

Boost Settings

  • Environment Root โ€“ a single directory containing all environments. For example, /var/www/example.com/.
  • Canonical Environment โ€“ With environment to use as the canonical source for content. This is typically dev before a site is launched, and prod once the site is launched.
  • VCS URL โ€“ This is the URL to checkout from version control. For example, git@github.com:imarc/example-com.git.
  • VCS Cache Directory โ€“ Boost keeps a local clone of the repository in this directory. Typically, something like /var/www/example.com/cache.
  • VCS Directories โ€“ This is a space separated list of relative paths to directories to copy from VCS into the environment as part of deployment. This might be something like
craft/plugins craft/templates public/css public/fonts public/img public/.htaccess composer.json

Database Settings

For each database, you can specify the name, user, password, and host. All of these are optional except for the production database name. If The development or staging database names are omitted, then they use the production name prefixed with 'dev_' or 'stage_' respectively., (*11)

Advanced Settings

  • Reset Ownership โ€“ If specified, this will reset the ownership of files synced from version control to this value. (Example: www-data:web).
  • Reset File Permissions โ€“ If specified, this is passed to chmod to reset the permissions of files and directories synced from version control. (Example: g+rw).
  • Keep Database โ€“ Boost's default behavior is to delete and recreate each database so that it will only contain tables/records from the export. However, if you do not have permissions to do this, You can enable this setting and Boost will make sure the export includes DROP TABLE statements, so that it can replace the tables in the target database without needing to remake it. It does mean that tables that are part of the target environment and not the source environment will persist.
  • Reset Database Permissions โ€“ If specified, database full database permissions are granted to this user when creating new databases. (Ex: web@localhost).
  • Delete Leftover Files โ€“ If specified, after the VCS directories are synced, leftover files present in the VCS directories but not in the repository will be deleted.
    • Protect From Deletion โ€“ A space separated list of files and folders that exist in the VCS directories on the server to protect from being deleted. (Ex: /writable*)

Hooks

  • Pre Deployment Hooks โ€“ These are run within the new environment before it is deployed live. This is a good place to run any additional build steps.
  • Post Deployment Hooks โ€“ These are run within the new environment after it is deployed live. This is a good place to run any kind of caching clearing.

Usage

To call this command, we use Craft's default CLI:, (*12)

php /var/www/<sitename>/prod/craft/app/etc/console/yiic.php boost

To deploy to a specific environment, use, (*13)

php /var/www/<sitename>/prod/craft/app/etc/console/yiic.php boost deploy --env=stage

To deploy to a branch to a specific environment, use, (*14)

php /var/www/<sitename>/prod/craft/app/etc/console/yiic.php boost deploy --env=stage --branch=branch-name

To show the log of commits that will be deployed to an env, (*15)

php /var/www/<sitename>/prod/craft/app/etc/console/yiic.php boost log --env=stage

Shows the current versions of each of the environments, (*16)

php /var/www/<sitename>/prod/craft/app/etc/console/yiic.php boost versions

The Versions

30/04 2018

dev-master

9999999-dev https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache-2.0 Apache

The Requires

 

by Kevin Hamer

30/04 2018

2.5.1

2.5.1.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache-2.0

The Requires

 

by Kevin Hamer

30/04 2018

2.5.0

2.5.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

10/08 2017

2.4.0

2.4.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

16/02 2017

2.3.1

2.3.1.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

16/02 2017

2.3.0

2.3.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

13/01 2017

2.2.0

2.2.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

14/10 2016

2.1.1

2.1.1.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

14/10 2016

2.1.0

2.1.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

25/08 2016

2.0.0

2.0.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

22/08 2016

1.2.0

1.2.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

06/07 2016

1.1.0

1.1.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

06/07 2016

dev-composer-support

dev-composer-support https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

05/05 2016

0.3.4

0.3.4.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

05/05 2016

1.0.2

1.0.2.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

28/04 2016

1.0.1

1.0.1.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

22/04 2016

1.0.0

1.0.0.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

22/04 2016

0.3.3

0.3.3.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

The Requires

 

by Kevin Hamer

20/04 2016

0.3.2

0.3.2.0 https://github.com/imarc/craft-boost

A Craft plugin that provides basic deployment.

  Sources   Download

Apache

by Kevin Hamer