Created
June 7, 2017 11:04
-
-
Save danitome24/6a90c6c89c8d5653eddadb6823e2aa4b to your computer and use it in GitHub Desktop.
Deployer for Silex app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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