Skip to content

Instantly share code, notes, and snippets.

@danitome24
Created June 7, 2017 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danitome24/6a90c6c89c8d5653eddadb6823e2aa4b to your computer and use it in GitHub Desktop.
Save danitome24/6a90c6c89c8d5653eddadb6823e2aa4b to your computer and use it in GitHub Desktop.
Deployer for Silex app
<?php
namespace Deployer;
require 'recipe/common.php';
// Configuration
set('repository', 'git@github.com:username/repo.git');
set('shared_files', ['config/parameters.yml']);
set('git_tty', true); // [Optional] Allocate tty for git on first deployment
set('shared_dirs', []);
set('writable_mode', 'chown');
set('writable_dirs', ['var/cache', 'var/logs']);
set('http_user', 'www-data');
set('http_group', 'www-data');
set('allow_anonymous_stats', false);
set('keep_releases', 5);
set('var_dir', 'var');
// Hosts
host('hostname')
->stage('prod')
->set('deploy_path', '/var/www/html/example.com');
/**
* Create cache dir
*/
task('deploy:create_cache_dir', function () {
// Set cache dir
set('cache_dir', '{{release_path}}/' . trim(get('var_dir'), '/') . '/cache');
// Remove cache dir if it exist
run('if [ -d "{{cache_dir}}" ]; then rm -rf {{cache_dir}}; fi');
// Create cache dir
run('mkdir -p {{cache_dir}}');
// Set rights
run('chmod -R g+w {{cache_dir}}');
})->desc('Create cache dir');
desc('Deploy your project');
task('deploy', [
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:vendors',
'deploy:clear_paths',
'deploy:create_cache_dir',
'deploy:writable',
'deploy:symlink',
'deploy:unlock',
'cleanup',
'success'
]);
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment