Options

onigoetz edited this page Jan 31, 2013 · 3 revisions
Clone this wiki locally

Configuration

Configuration is really easy and everything is done in one array.

File Structure

The options I recommend are :

<?php
    ...
    'directories' => array(
        'base_dir' => '/path_to_your_web_files/www/',
        'snapshots' => 'deploy/snapshots',
        'deploy' => 'www',
        //http://php.net/manual/en/function.strftime.php
        'snapshot_pattern' => '%G-%m-%d_%H-%M'
    ),
    ...

this makes the following file structure :

base_dir/             -- 'base_dir' variable
  deploy/snapshots/   -- 'snapshots' variable, here the raw repositories will be deployed
  www                 -- 'deploy' variable, point your webserver to this folder

I also have the habit to create a resources folder that I use for the images and other folders that I need to symlink before I publish the new release.

Example

An example of configuration file :

<?php
$config = array(
    'deploy' => array(
        //Where to get the files to deploy
        'scm' => array(
            'type' => 'git',
            //optional if final_url is provided
            //'repository' => 'https://github.com/onigoetz/Youmewine.git',
            //'username' => 'onigoetz',

            'final_url' => 'git@github.com:onigoetz/Youmewine.git',
            'branch' => 'master',
            'options' => array(
                'submodules' => true
            )
        ),
        //Where to put the files to deploy
        'directories' => array(
            'base_dir' => '/home/youmewine/www/',
            'snapshots' => 'deploy/snapshots',
            'deploy' => 'www',
            //http://php.net/manual/en/function.strftime.php
            'snapshot_pattern' => '%G-%m-%d_%H-%M'
        ),
        //What to do before the deploy
        'actions_before' => array(
            array(
                'description' => 'Link the images',
                'action' => 'symlink',
                'target' => 'resources/images',
                'link_name' => '${snapshot}/images'
            ),
            array(
                'description' => 'Security : Remove deploy file',
                'action' => 'rmfile',
                'dir' => '${snapshot}/deploy.php'
            ),
            array(
                'description' => 'Composer',
                'action' => 'composer',
                'dir' => '${snapshot}/application'
            )
        ),
        //What to do after the deploy (when the symlink is changed)
        'actions_after' => array(
        )
    ),
    'servers' => array(
        array(
            'host' => 'example01.net',
            'username' => 'example',
            //Password is optional, if it's not provided, it will be asked at runtime
        )
    ),
    'environments' => array(
        'prod' => array(
            //Servers are optional in the environements, if it's specified, it replaces the default servers
            'servers' => array(
                array(
                    'host' => 'example.com',
                    'username' => 'example',
                )
            )
        ),
        'dev' => array(
            'deploy' => array(
                'scm' => array('branch' => 'develop'),
                'directories' => array('base_dir' => '/home/youmewine/domains/dev.youmewine.com/www/'),
            )
        ),
        'demo' => array(
            'deploy' => array(
                'scm' => array('branch' => 'develop'),
                'directories' => array('base_dir' => '/home/youmewine/domains/demo.youmewine.com/www/'),
            )
        )
    )
);

Categories

Deploy

Servers

Environments

Here you specify the environment's name and environment specific values, you can override any value of the two first categories.

The deploy options will overwrite per option. so you can specify only the options that you want. But for the server options, it will replace the array, keep that in mind

    'environments' => array(
        'prod' => array(
            'deploy' => array(
                ...
            ),
            'servers' => array(
                ...
            ),

        ),
        ...
    )