Skip to content

Instantly share code, notes, and snippets.

@ariefbayu
Created September 25, 2018 12:15
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 ariefbayu/fb9e564a23c60f6d3582166922b4dbbf to your computer and use it in GitHub Desktop.
Save ariefbayu/fb9e564a23c60f6d3582166922b4dbbf to your computer and use it in GitHub Desktop.
<?php
namespace Deployer;
require 'recipe/symfony.php';
set('bin_dir', 'bin');
set('var_dir', 'var');
set('env', [
'SYMFONY_ENV' => 'staging',
]);
// Project name
set('application', 'izzy inventory');
// Project repository
set('repository', 'git@gitlab.com:jobSmart-Team/izzy-inventory.git');
#set('repository', 'https://gitlab.com/jobSmart-Team/izzy-inventory.git');
// [Optional] Allocate tty for git clone. Default value is false.
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']);
//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('chmod -R 777 {{release_path}}/var/logs/');
run('cd {{release_path}} && composer install && composer dump-autoload --optimize');
run('cp {{release_path}}/web/.htaccess_staging {{release_path}}/web/.htaccess');
})->onStage('staging');
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');
})->onStage('staging');
after('deploy:assets', 'build')->onStage('staging');
after('build', 'database:schema:update')->onStage('staging');
after('deploy:failed', 'deploy:unlock')->onStage('staging');
//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');
})->onStage('production');
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');
})->onStage('production');
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