1 | <?php |
||
2 | namespace Deployer; |
||
3 | |||
4 | require_once __DIR__ . '/common.php'; |
||
5 | |||
6 | // Configuration |
||
7 | |||
8 | // By default setup:static-content:deploy uses `en_US`. |
||
9 | // To change that, simply put set('static_content_locales', 'en_US de_DE');` |
||
10 | // in you deployer script. |
||
11 | set('static_content_locales', 'en_US'); |
||
12 | |||
13 | set('shared_files', [ |
||
14 | 'app/etc/env.php', |
||
15 | 'var/.maintenance.ip', |
||
16 | ]); |
||
17 | set('shared_dirs', [ |
||
18 | 'var/composer_home', |
||
19 | 'var/log', |
||
20 | 'var/cache', |
||
21 | 'var/export', |
||
22 | 'var/report', |
||
23 | 'var/import_history', |
||
24 | 'var/session', |
||
25 | 'var/importexport', |
||
26 | 'var/backups', |
||
27 | 'var/tmp', |
||
28 | 'pub/sitemaps', |
||
29 | 'pub/media' |
||
30 | ]); |
||
31 | set('writable_dirs', [ |
||
32 | 'var', |
||
33 | 'pub/static', |
||
34 | 'pub/media', |
||
35 | 'generated' |
||
36 | ]); |
||
37 | set('clear_paths', [ |
||
38 | 'generated/*', |
||
39 | 'pub/static/_cache/*', |
||
40 | 'var/generation/*', |
||
41 | 'var/cache/*', |
||
42 | 'var/page_cache/*', |
||
43 | 'var/view_preprocessed/*' |
||
44 | ]); |
||
45 | |||
46 | // Tasks |
||
47 | desc('Compile magento di'); |
||
48 | task('magento:compile', function () { |
||
49 | run("{{bin/php}} {{release_path}}/bin/magento setup:di:compile"); |
||
50 | run('cd {{release_path}} && {{bin/composer}} dump-autoload -o'); |
||
51 | }); |
||
52 | |||
53 | desc('Deploy assets'); |
||
54 | task('magento:deploy:assets', function () { |
||
55 | run("{{bin/php}} {{release_path}}/bin/magento setup:static-content:deploy {{static_content_locales}}"); |
||
56 | }); |
||
57 | |||
58 | desc('Enable maintenance mode'); |
||
59 | task('magento:maintenance:enable', function () { |
||
60 | run("if [ -d $(echo {{deploy_path}}/current) ]; then {{bin/php}} {{deploy_path}}/current/bin/magento maintenance:enable; fi"); |
||
61 | }); |
||
62 | |||
63 | desc('Disable maintenance mode'); |
||
64 | task('magento:maintenance:disable', function () { |
||
65 | run("if [ -d $(echo {{deploy_path}}/current) ]; then {{bin/php}} {{deploy_path}}/current/bin/magento maintenance:disable; fi"); |
||
66 | }); |
||
67 | |||
68 | desc('Upgrade magento database'); |
||
69 | task('magento:upgrade:db', function () { |
||
70 | run("{{bin/php}} {{release_path}}/bin/magento setup:upgrade --keep-generated"); |
||
71 | }); |
||
72 | |||
73 | desc('Flush Magento Cache'); |
||
74 | task('magento:cache:flush', function () { |
||
75 | run("{{bin/php}} {{release_path}}/bin/magento cache:flush"); |
||
76 | }); |
||
77 | |||
78 | desc('Magento2 deployment operations'); |
||
79 | task('deploy:magento', [ |
||
80 | 'magento:compile', |
||
81 | 'magento:deploy:assets', |
||
82 | 'magento:maintenance:enable', |
||
83 | 'magento:upgrade:db', |
||
84 | 'magento:cache:flush', |
||
85 | 'magento:maintenance:disable' |
||
86 | ]); |
||
87 | |||
88 | desc('Deploy your project'); |
||
89 | task('deploy', [ |
||
90 | 'deploy:info', |
||
91 | 'deploy:setup', |
||
92 | 'deploy:lock', |
||
93 | 'deploy:release', |
||
94 | 'deploy:update_code', |
||
95 | 'deploy:shared', |
||
96 | 'deploy:vendors', |
||
97 | 'deploy:writable', |
||
98 | 'deploy:clear_paths', |
||
99 | 'deploy:magento', |
||
100 | 'deploy:symlink', |
||
101 | 'deploy:unlock', |
||
102 | 'deploy:cleanup', |
||
103 | 'success' |
||
104 | ]); |
||
105 | |||
106 | after('deploy:failed', 'magento:maintenance:disable'); |
||
107 |