Skip to content

Commit

Permalink
Merge pull request #29 from unleashedtech/magento2-auth-json-shared
Browse files Browse the repository at this point in the history
Magento2 auth json shared
  • Loading branch information
dl-unleashed-technologies authored Jun 24, 2022
2 parents 7ca469c + 67f1f1c commit efa6606
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 80 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi

## [Unreleased][unreleased]

## [0.3.24] - 2022-06-09
## [0.4.0] - 2022-06-24

### Changed

- Deployer and Composer deprecated the dist install and with this change they
- Updated Magento recipe shared dirs & files directives to better support
Magento's Git restrictions.
- Deployer and Composer deprecated the dist install and with this change they
also changed what exists in the vendor/bin directory. Deployer.phar is in
vendor/bin instead of dep. All calls (in scripts) to deployer should be
changed accordingly. This change gets rid of the composer deprecation warning
that showed up during composer installs.
- Add 30 minute timeout to magento2 commands.
- Add 30 minute timeout to magento2 commands.

#### Removed

Expand Down Expand Up @@ -334,7 +336,8 @@ config vars to be overridden.

**Initial release!**

[unreleased]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.24...main
[unreleased]: https://github.com/unleashedtech/deployer-recipes/compare/0.4.0...main
[0.4.0]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.24...0.4.0
[0.3.24]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.23...0.3.24
[0.3.23]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.22...0.3.23
[0.3.22]: https://github.com/unleashedtech/deployer-recipes/compare/0.3.21...0.3.22
Expand Down
176 changes: 100 additions & 76 deletions cms/magento/magento2.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,51 @@
set('timeout', 60 * 30);

// Please see notes in the magento README regarding the permissions for the parents of these files.
fill('shared_dirs', [
'var/composer_home',
'var/log',
'var/export',
'var/report',
'var/import',
'var/import_history',
'var/session',
'var/importexport',
'var/backups',
'var/tmp',
'pub/media',
'pub/page-cache',
'pub/sitemap',
'pub/static',
]);
fill(
'shared_dirs',
[
'var/composer_home',
'var/log',
'var/export',
'var/report',
'var/import',
'var/import_history',
'var/session',
'var/importexport',
'var/backups',
'var/tmp',
'pub/media',
'pub/page-cache',
'pub/sitemap',
'pub/static',
]
);

// Please see notes in the magento README regarding the permissions for this file.
fill('shared_files', [
'app/etc/env.php',
]);
fill(
'shared_files',
[
'app/etc/env.php',
'docroot/auth.json',
]
);

// Please see notes in the magento README regarding the permissions for the directories that are writable
// At UT we believe the deployer user should not be running chown for each deploy.
fill('writable_dirs', []);

// Please see notes in the magento README regarding the permissions for the directories that are writable
fill('clear_paths', [
'generated/*',
'pub/static/_cache/*',
'var/generation/*',
'var/cache/*',
'var/page_cache/*',
'var/view_preprocessed/*',
]);
fill(
'clear_paths',
[
'generated/*',
'pub/static/_cache/*',
'var/generation/*',
'var/cache/*',
'var/page_cache/*',
'var/view_preprocessed/*',
]
);
fill('app_directory_name', 'docroot');
set('static_content_locales', 'en_US');
set('http_user', 'www-data');
Expand All @@ -70,34 +80,40 @@
*
* The `writable_dirs` array can be manually overridden in `deploy.yaml`.
*/
task('magento:init', static function (): void {
$vars = ['shared_dirs', 'shared_files', 'writable_dirs', 'clear_paths'];
$appDir = get('app_directory_name');

foreach ($vars as $var) {
$newVars = [];
foreach (get($var) as $fileDir) {
$newVars[] = $appDir . '/' . $fileDir;
}
task(
'magento:init',
static function (): void {
$vars = ['shared_dirs', 'shared_files', 'writable_dirs', 'clear_paths'];
$appDir = get('app_directory_name');

set($var, $newVars);
}
});
foreach ($vars as $var) {
$newVars = [];
foreach (get($var) as $fileDir) {
$newVars[] = $appDir . '/' . $fileDir;
}

desc('Enables maintenance mode');
task('magento:maintenance:enable', static function (): void {
$exists = test('[ -d {{current_path}} ]');
if (! $exists) {
return;
set($var, $newVars);
}
}
);

within(
'{{release_or_current_path}}/{{app_directory_name}}',
static function (): void {
run('{{mage}} maintenance:enable');
desc('Enables maintenance mode');
task(
'magento:maintenance:enable',
static function (): void {
$exists = test('[ -d {{current_path}} ]');
if (! $exists) {
return;
}
);
});

within(
'{{release_or_current_path}}/{{app_directory_name}}',
static function (): void {
run('{{mage}} maintenance:enable');
}
);
}
);

desc('Disables maintenance mode');
task(
Expand Down Expand Up @@ -297,12 +313,15 @@ static function (): void {
}
);

task('magento:db:pull', static function (): void {
invoke('magento:db:backup:create');
invoke('db:backup:download');
invoke('magento:db:backup:import');
invoke('db:backup:cleanup');
});
task(
'magento:db:pull',
static function (): void {
invoke('magento:db:backup:create');
invoke('db:backup:download');
invoke('magento:db:backup:import');
invoke('db:backup:cleanup');
}
);

desc('Deploy Static Assets');
/**
Expand Down Expand Up @@ -352,27 +371,32 @@ static function (): void {
import('vendor/unleashedtech/deployer-recipes/releases/cleanup.php');

desc('Magento2 Deployment Tasks');
task('deploy:magento2', [
'magento:deploy:vendor',
'magento:db:backup:create',
'magento:maintenance:enable',
'magento:prod:mode',
'magento:config:import',
'magento:setup:upgrade',
'magento:cache:flush',
'magento:indexer:reindex',
'magento:cron',
'magento:maintenance:disable',
]);

task('deploy', [
'magento:init',
'deploy:prepare',
'deploy:vendors',
'deploy:clear_paths',
task(
'deploy:magento2',
'deploy:publish',
]);
[
'magento:deploy:vendor',
'magento:db:backup:create',
'magento:prod:mode',
'magento:config:import',
'magento:setup:upgrade',
'magento:cache:flush',
'magento:indexer:reindex',
'magento:cron',
'magento:maintenance:disable',
]
);

task(
'deploy',
[
'magento:init',
'deploy:prepare',
'deploy:vendors',
'deploy:clear_paths',
'deploy:magento2',
'deploy:publish',
]
);

after('deploy:failed', 'magento:maintenance:disable');
after('deploy:failed', 'deploy:unlock');

0 comments on commit efa6606

Please sign in to comment.