Skip to content

Instantly share code, notes, and snippets.

@igancev
Last active January 7, 2018 08:29
Show Gist options
  • Save igancev/ba4b57c04a33799e17f38c90830114c8 to your computer and use it in GitHub Desktop.
Save igancev/ba4b57c04a33799e17f38c90830114c8 to your computer and use it in GitHub Desktop.
Deployer + laradock + yii2 deploy production
<?php
namespace Deployer;
require 'recipe/yii2-app-advanced.php';
set('ssh_multiplexing', true);
set('bin/php', 'php');
set('repository', 'https://bitbucket.org/*****/*****');
set('git_tty', true);
// production
host('165.177.**.**')
->stage('prod')
->user('*****')
->set('deploy_path', '/home/*****/app')
->forwardAgent();
set('shared_dirs', [
'frontend/runtime',
'backend/runtime',
'console/runtime',
'common/runtime',
'api/runtime',
]);
set('shared_files', [
'common/config/main-local.php',
'common/config/params-local.php',
'frontend/config/main-local.php',
'frontend/config/params-local.php',
'backend/config/main-local.php',
'backend/config/params-local.php',
'console/config/main-local.php',
'console/config/params-local.php',
'api/config/main-local.php',
'api/config/params-local.php',
]);
task('deploy:vendors', function () {
cd('/home/*****/laradock');
$result = run('docker-compose exec -T workspace bash -c \'cd /var/www/release && composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader\'');
writeln("$result");
});
task('deploy:init', function () {
cd('/home/*****/laradock');
$result = run('docker-compose exec -T workspace bash -c \'php /var/www/releases/{{release_name}}/init --env=Production --overwrite=n\'');
writeln("$result");
})->desc('Initialization');
task('deploy:run_migrations', function () {
cd('/home/*****/laradock');
$result = run('docker-compose exec -T workspace bash -c \'php /var/www/releases/{{release_name}}/yii migrate up --interactive=0\'');
writeln("$result");
})->desc('Run migrations');
/*
* Tasks
*/
// [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