-
-
Save ariefbayu/66e2158498e052a6f85fcdb0183c03a2 to your computer and use it in GitHub Desktop.
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/symfony.php'; | |
$stage = ''; | |
if(isset($argv)){ | |
$stage = isset($argv[2]) ? $argv[2] : ''; | |
} else if(isset($GLOBALS['argv'])) { | |
$stage = isset($GLOBALS['argv'][2]) ? $GLOBALS['argv'][2] : ''; | |
} | |
if(!in_array($stage, array('staging', 'production'))){ | |
$message = "Deployer only accept \$stage: 'staging' or 'production'.\n"; | |
$message .= "Use the following command: bin/dep deploy {{stage}}\n"; | |
die($message); | |
} | |
set('bin_dir', 'bin'); | |
set('var_dir', 'var'); | |
// Project name | |
set('application', 'izzy inventory'); | |
// Project repository | |
set('repository', 'git@gitlab.com:jobSmart-Team/izzy-inventory.git'); | |
set('git_tty', false); | |
// Shared files/dirs between deploys | |
add('shared_files', ['app/config/parameters.yml']); | |
add('shared_dirs', ['var/logs', 'var/sessions']); | |
// Writable dirs by web server | |
add('writable_dirs', ['var/cache', 'var/logs', 'var/sessions']); | |
if($stage == 'staging'){ | |
set('env', [ | |
'SYMFONY_ENV' => 'staging', | |
]); | |
//Config for Staging: | |
host('staging-ip') | |
->stage('staging') | |
->user('iinventory') | |
->set('deploy_path', '/home/iinventory/staging.izzyinventory.com/'); | |
task('build', function () { | |
run('chmod -R 775 {{deploy_path}}/releases/'); | |
run('cd {{release_path}} && composer install && composer dump-autoload --optimize'); | |
run('cp {{release_path}}/web/.htaccess_staging {{release_path}}/web/.htaccess'); | |
}); | |
task('database:schema:update', function() { | |
run('php {{release_path}}/bin/console doctrine:schema:update --force --env=staging'); | |
run('php {{release_path}}/bin/console cache:clear --env=staging'); | |
}); | |
after('deploy:assets', 'build'); | |
after('build', 'database:schema:update'); | |
after('deploy:failed', 'deploy:unlock'); | |
} | |
if($stage == 'production'){ | |
//Config for Production: | |
host('production-ip') | |
->stage('production') | |
->user('willy') | |
->set('deploy_path', '/srv/users/willy/apps/izzyinventory'); | |
task('build', function () { | |
run('chmod -R 775 {{deploy_path}}/releases/'); | |
run('cd {{release_path}} && composer install && composer dump-autoload --optimize'); | |
run('cp {{release_path}}/web/.htaccess_prod {{release_path}}/web/.htaccess'); | |
}); | |
task('database:schema:update', function() { | |
run('php {{release_path}}/bin/console doctrine:schema:update --force --env=prod'); | |
run('php {{release_path}}/bin/console cache:clear --env=prod'); | |
}); | |
after('deploy:assets', 'build'); | |
after('build', 'database:schema:update'); | |
after('deploy:failed', 'deploy:unlock'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment