2016-11-28 11:11:23 +01:00
|
|
|
<?php
|
|
|
|
namespace Deployer;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
|
|
|
|
// Configuration
|
2020-04-25 23:00:08 +03:00
|
|
|
|
|
|
|
// By default setup:static-content:deploy uses `en_US`.
|
|
|
|
// To change that, simply put set('static_content_locales', 'en_US de_DE');`
|
|
|
|
// in you deployer script.
|
|
|
|
set('static_content_locales', 'en_US');
|
|
|
|
|
2017-01-19 11:38:37 +07:00
|
|
|
set('shared_files', [
|
|
|
|
'app/etc/env.php',
|
|
|
|
'var/.maintenance.ip',
|
|
|
|
]);
|
|
|
|
set('shared_dirs', [
|
2019-05-26 03:30:18 -04:00
|
|
|
'var/composer_home',
|
2017-01-19 11:38:37 +07:00
|
|
|
'var/log',
|
2019-05-26 03:30:18 -04:00
|
|
|
'var/cache',
|
|
|
|
'var/export',
|
|
|
|
'var/report',
|
|
|
|
'var/import_history',
|
|
|
|
'var/session',
|
|
|
|
'var/importexport',
|
2017-01-19 11:38:37 +07:00
|
|
|
'var/backups',
|
2019-05-26 03:30:18 -04:00
|
|
|
'var/tmp',
|
|
|
|
'pub/sitemaps',
|
|
|
|
'pub/media'
|
2017-01-19 11:38:37 +07:00
|
|
|
]);
|
|
|
|
set('writable_dirs', [
|
|
|
|
'var',
|
|
|
|
'pub/static',
|
|
|
|
'pub/media',
|
2019-07-05 23:27:27 +02:00
|
|
|
'generated'
|
2017-01-19 11:38:37 +07:00
|
|
|
]);
|
|
|
|
set('clear_paths', [
|
2019-07-05 23:27:27 +02:00
|
|
|
'generated/*',
|
2019-05-26 03:30:18 -04:00
|
|
|
'pub/static/_cache/*',
|
2017-01-19 11:38:37 +07:00
|
|
|
'var/generation/*',
|
|
|
|
'var/cache/*',
|
2019-05-26 03:30:18 -04:00
|
|
|
'var/page_cache/*',
|
|
|
|
'var/view_preprocessed/*'
|
2017-01-19 11:38:37 +07:00
|
|
|
]);
|
2016-11-28 11:11:23 +01:00
|
|
|
|
|
|
|
// Tasks
|
|
|
|
desc('Compile magento di');
|
|
|
|
task('magento:compile', function () {
|
|
|
|
run("{{bin/php}} {{release_path}}/bin/magento setup:di:compile");
|
2017-09-18 11:23:21 +02:00
|
|
|
run('cd {{release_path}} && {{bin/composer}} dump-autoload -o');
|
2016-11-28 11:11:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
desc('Deploy assets');
|
|
|
|
task('magento:deploy:assets', function () {
|
2020-04-25 23:00:08 +03:00
|
|
|
run("{{bin/php}} {{release_path}}/bin/magento setup:static-content:deploy {{static_content_locales}}");
|
2016-11-28 11:11:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
desc('Enable maintenance mode');
|
|
|
|
task('magento:maintenance:enable', function () {
|
2017-03-21 18:02:16 +01:00
|
|
|
run("if [ -d $(echo {{deploy_path}}/current) ]; then {{bin/php}} {{deploy_path}}/current/bin/magento maintenance:enable; fi");
|
2016-11-28 11:11:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
desc('Disable maintenance mode');
|
|
|
|
task('magento:maintenance:disable', function () {
|
2017-03-21 18:02:16 +01:00
|
|
|
run("if [ -d $(echo {{deploy_path}}/current) ]; then {{bin/php}} {{deploy_path}}/current/bin/magento maintenance:disable; fi");
|
2016-11-28 11:11:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
desc('Upgrade magento database');
|
|
|
|
task('magento:upgrade:db', function () {
|
2017-12-14 17:24:59 +01:00
|
|
|
run("{{bin/php}} {{release_path}}/bin/magento setup:upgrade --keep-generated");
|
2016-11-28 11:11:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
desc('Flush Magento Cache');
|
|
|
|
task('magento:cache:flush', function () {
|
|
|
|
run("{{bin/php}} {{release_path}}/bin/magento cache:flush");
|
|
|
|
});
|
|
|
|
|
2017-01-19 11:38:37 +07:00
|
|
|
desc('Magento2 deployment operations');
|
|
|
|
task('deploy:magento', [
|
|
|
|
'magento:compile',
|
|
|
|
'magento:deploy:assets',
|
|
|
|
'magento:maintenance:enable',
|
|
|
|
'magento:upgrade:db',
|
|
|
|
'magento:cache:flush',
|
|
|
|
'magento:maintenance:disable'
|
|
|
|
]);
|
|
|
|
|
2016-11-28 11:11:23 +01:00
|
|
|
desc('Deploy your project');
|
|
|
|
task('deploy', [
|
2017-08-12 12:01:27 +03:00
|
|
|
'deploy:info',
|
2020-04-25 23:00:08 +03:00
|
|
|
'deploy:setup',
|
2016-11-28 11:11:23 +01:00
|
|
|
'deploy:lock',
|
|
|
|
'deploy:release',
|
|
|
|
'deploy:update_code',
|
|
|
|
'deploy:shared',
|
|
|
|
'deploy:vendors',
|
2018-08-01 11:43:29 +01:00
|
|
|
'deploy:writable',
|
2016-11-28 11:11:23 +01:00
|
|
|
'deploy:clear_paths',
|
2017-01-19 11:38:37 +07:00
|
|
|
'deploy:magento',
|
2016-11-28 11:11:23 +01:00
|
|
|
'deploy:symlink',
|
|
|
|
'deploy:unlock',
|
2020-04-25 23:00:08 +03:00
|
|
|
'deploy:cleanup',
|
2016-11-28 11:11:23 +01:00
|
|
|
'success'
|
|
|
|
]);
|
2017-05-30 10:42:37 +02:00
|
|
|
|
|
|
|
after('deploy:failed', 'magento:maintenance:disable');
|