From 0a2f5ff5437beb0612671437d0f30e7d2bc1de4c Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Wed, 18 Jan 2023 17:02:31 +0000 Subject: [PATCH 1/7] DD#0000: feat: Updated magento2 config to generate a new cache id each deployment --- recipe/magento2.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/recipe/magento2.php b/recipe/magento2.php index b1cf028f6..0a117816a 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -12,6 +12,8 @@ const CONFIG_IMPORT_NEEDED_EXIT_CODE = 2; const DB_UPDATE_NEEDED_EXIT_CODE = 2; const MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG = 'maintenance mode is active'; +const ENV_CONFIG_FILE_PATH = 'app/etc/env.php'; +const TMP_ENV_CONFIG_FILE_PATH = 'app/etc/env_tmp.php'; add('recipes', ['magento2']); @@ -434,6 +436,47 @@ function magentoDeployAssetsSplit(string $area) add('shared_dirs', get('additional_shared_dirs')); }); +/** + * Update cache ip_prefix on deploy so that you are compiling against a fresh cache + * Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 + **/ +desc('Update cache id_prefix'); +task('magento:set_cache_prefix', function () { + //get current env config + $envConfigString = run("cat {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH); + $envConfig = eval('?>'.$envConfigString); + //set prefix to `alias_releasename_` + $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; + + //update id_prefix to include release name + $envConfig["cache"]["frontend"]["default"]["id_prefix"] = $prefixUpdate; + $envConfig["cache"]["frontend"]["page_cache"]["id_prefix"] = $prefixUpdate; + + //Generate configuration array as string + $envConfigStr = " {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH); + //delete the symlink for env.php + run("rm {{release_or_current_path}}/" . ENV_CONFIG_FILE_PATH); + //link the env to the tmp version + run("{{bin/symlink}} {{deploy_path}}/shared/" . TMP_ENV_CONFIG_FILE_PATH . " {{release_path}}/" . ENV_CONFIG_FILE_PATH); +}); +after('deploy:shared', 'magento:set_cache_prefix'); + +/** + * After successful deployment, move the tmp_env.php file to env.php ready for next deployment + */ +desc('Cleanup cache id_prefix env files'); +task('magento:cleanup_cache_prefix', function () { + run("rm {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH); + run("rm {{release_or_current_path}}/" . ENV_CONFIG_FILE_PATH); + run("mv {{deploy_path}}/shared/" . TMP_ENV_CONFIG_FILE_PATH . " {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH); + // Symlink shared dir to release dir + run("{{bin/symlink}} {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH . " {{release_path}}/" . ENV_CONFIG_FILE_PATH); +}); +after('deploy:magento', 'magento:cleanup_cache_prefix'); + desc('Prepares an artifact on the target server'); task('artifact:prepare', [ From 82d2b1e2613fbb57865b7063b5361d13994867bb Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Fri, 10 Mar 2023 17:29:40 +0000 Subject: [PATCH 2/7] DD#0000: feat: Updated double quotes to singles --- recipe/magento2.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 0a117816a..37aa2f017 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -437,30 +437,29 @@ function magentoDeployAssetsSplit(string $area) }); /** - * Update cache ip_prefix on deploy so that you are compiling against a fresh cache + * Update cache id_prefix on deploy so that you are compiling against a fresh cache * Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 **/ desc('Update cache id_prefix'); task('magento:set_cache_prefix', function () { //get current env config - $envConfigString = run("cat {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH); + $envConfigString = run('cat {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); $envConfig = eval('?>'.$envConfigString); //set prefix to `alias_releasename_` $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; //update id_prefix to include release name - $envConfig["cache"]["frontend"]["default"]["id_prefix"] = $prefixUpdate; - $envConfig["cache"]["frontend"]["page_cache"]["id_prefix"] = $prefixUpdate; - + $envConfig['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; + $envConfig['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; //Generate configuration array as string - $envConfigStr = " {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH); //delete the symlink for env.php - run("rm {{release_or_current_path}}/" . ENV_CONFIG_FILE_PATH); + run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); //link the env to the tmp version - run("{{bin/symlink}} {{deploy_path}}/shared/" . TMP_ENV_CONFIG_FILE_PATH . " {{release_path}}/" . ENV_CONFIG_FILE_PATH); + run('{{bin/symlink}} {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); }); after('deploy:shared', 'magento:set_cache_prefix'); @@ -469,11 +468,11 @@ function magentoDeployAssetsSplit(string $area) */ desc('Cleanup cache id_prefix env files'); task('magento:cleanup_cache_prefix', function () { - run("rm {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH); - run("rm {{release_or_current_path}}/" . ENV_CONFIG_FILE_PATH); - run("mv {{deploy_path}}/shared/" . TMP_ENV_CONFIG_FILE_PATH . " {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH); + run('rm {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); + run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); + run('mv {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); // Symlink shared dir to release dir - run("{{bin/symlink}} {{deploy_path}}/shared/" . ENV_CONFIG_FILE_PATH . " {{release_path}}/" . ENV_CONFIG_FILE_PATH); + run('{{bin/symlink}} {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); }); after('deploy:magento', 'magento:cleanup_cache_prefix'); From b09740dbfd94279d0313fb7e5a312e72a284bc7a Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Fri, 10 Mar 2023 17:35:24 +0000 Subject: [PATCH 3/7] DD#0000: feat: Added an option to enable feature --- recipe/magento2.php | 52 ++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 37aa2f017..dd28a1911 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -145,6 +145,9 @@ // Deploy without setting maintenance mode if possible set('enable_zerodowntime', true); +//deploy with auto updating cache index_prefix +set('use_redis_cache_id', false); + // Tasks // To work correctly with artifact deployment, it is necessary to set the MAGE_MODE correctly in `app/etc/config.php` @@ -439,27 +442,30 @@ function magentoDeployAssetsSplit(string $area) /** * Update cache id_prefix on deploy so that you are compiling against a fresh cache * Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 + * use set('use_redis_cache_id') in your deployer script to enable **/ desc('Update cache id_prefix'); task('magento:set_cache_prefix', function () { //get current env config - $envConfigString = run('cat {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); - $envConfig = eval('?>'.$envConfigString); - //set prefix to `alias_releasename_` - $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; - - //update id_prefix to include release name - $envConfig['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; - $envConfig['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; - //Generate configuration array as string - $envConfigStr = ' {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH); - //delete the symlink for env.php - run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); - //link the env to the tmp version - run('{{bin/symlink}} {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); + if (get('use_redis_cache_id')) { + $envConfigString = run('cat {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); + $envConfig = eval('?>' . $envConfigString); + //set prefix to `alias_releasename_` + $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; + + //update id_prefix to include release name + $envConfig['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; + $envConfig['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; + //Generate configuration array as string + $envConfigStr = ' {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH); + //delete the symlink for env.php + run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); + //link the env to the tmp version + run('{{bin/symlink}} {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); + } }); after('deploy:shared', 'magento:set_cache_prefix'); @@ -468,11 +474,13 @@ function magentoDeployAssetsSplit(string $area) */ desc('Cleanup cache id_prefix env files'); task('magento:cleanup_cache_prefix', function () { - run('rm {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); - run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); - run('mv {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); - // Symlink shared dir to release dir - run('{{bin/symlink}} {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); + if (get('use_redis_cache_id')) { + run('rm {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); + run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); + run('mv {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); + // Symlink shared dir to release dir + run('{{bin/symlink}} {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH); + } }); after('deploy:magento', 'magento:cleanup_cache_prefix'); From 99267c3693ad452d508eb059270a0f05bfd785f7 Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Fri, 10 Mar 2023 17:36:42 +0000 Subject: [PATCH 4/7] DD#0000: feat: Updated docs --- docs/recipe/magento2.md | 130 ++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 51 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index db112eb35..8a6357853 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -115,7 +115,7 @@ The magento2 recipe is based on the [common](/docs/recipe/common.md) recipe. ## Configuration ### static_content_locales -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L23) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L25) By default setup:static-content:deploy uses `en_US`. To change that, simply put `set('static_content_locales', 'en_US de_DE');` @@ -127,7 +127,7 @@ in you deployer script. ### magento_themes -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L40) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L42) You can also set the themes to run against. By default it'll deploy all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` @@ -151,14 +151,14 @@ set('magento_themes', [ ### static_deploy_options -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L45) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L47) Static content deployment options, e.g. '--no-parent' ### split_static_deployment -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L48) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L50) Deploy frontend and adminhtml together as default @@ -168,7 +168,7 @@ false ### static_content_locales_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L53) Use the default languages for the backend as default @@ -178,7 +178,7 @@ Use the default languages for the backend as default ### magento_themes_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L55) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L57) backend themes to deploy. Only used if split_static_deployment=true This setting supports the same options/structure as [magento_themes](/docs/recipe/magento2.md#magento_themes) @@ -189,7 +189,7 @@ This setting supports the same options/structure as [magento_themes](/docs/recip ### static_content_jobs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L61) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L63) Also set the number of conccurent jobs to run. The default is 1 Update using: `set('static_content_jobs', '1');` @@ -200,7 +200,7 @@ Update using: `set('static_content_jobs', '1');` ### content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L63) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L65) @@ -210,7 +210,7 @@ return time(); ### magento_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L68) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L70) Magento directory relative to repository root. Use "." (default) if it is not located in a subdirectory @@ -220,7 +220,7 @@ Magento directory relative to repository root. Use "." (default) if it is not lo ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L71) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L73) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -235,7 +235,7 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L75) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L77) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -261,7 +261,7 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L90) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -279,7 +279,7 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L97) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L99) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -298,7 +298,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### bin/magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L106) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L108) @@ -308,7 +308,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L108) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L110) @@ -321,7 +321,7 @@ return $matches[0] ?? '2.0'; ### config_import_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L115) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L117) :::info Autogenerated @@ -332,7 +332,7 @@ The value of this configuration is autogenerated on access. ### database_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L129) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131) :::info Autogenerated @@ -343,7 +343,7 @@ The value of this configuration is autogenerated on access. ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L144) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L146) Deploy without setting maintenance mode if possible @@ -352,8 +352,18 @@ true ``` +### use_redis_cache_id +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L149) + +deploy with auto updating cache index_prefix + +```php title="Default value" +false +``` + + ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L330) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L335) The file the artifact is saved to @@ -363,7 +373,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L333) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L338) The directory the artifact is saved in @@ -373,7 +383,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L337) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L342) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -384,7 +394,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L340) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L345) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -394,7 +404,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L343) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -406,7 +416,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L346) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L351) The relative path to the artifact file. If the directory does not exist, it will be created @@ -419,7 +429,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L354) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L359) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -430,14 +440,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L426) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L431) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L433) Array of shared directories that will be added to the default shared_dirs without overriding @@ -447,7 +457,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L154) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) Compiles magento di. @@ -459,7 +469,7 @@ e.g. ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L180) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L185) Deploys assets. @@ -486,7 +496,7 @@ in `app/etc/config.php`, e.g.: ### magento:deploy:assets:adminhtml -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L196) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L201) Deploys assets for backend only. @@ -494,7 +504,7 @@ Deploys assets for backend only. ### magento:deploy:assets:frontend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L201) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L206) Deploys assets for frontend only. @@ -502,7 +512,7 @@ Deploys assets for frontend only. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L249) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L254) Syncs content version. @@ -510,7 +520,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L259) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L264) Enables maintenance mode. @@ -518,7 +528,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L265) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L270) Disables maintenance mode. @@ -526,7 +536,7 @@ Disables maintenance mode. ### magento:maintenance:enable-if-needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L271) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L276) Set maintenance mode if needed. @@ -534,7 +544,7 @@ Set maintenance mode if needed. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L278) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L283) Config Import. @@ -542,7 +552,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L287) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L292) Upgrades magento database. @@ -550,7 +560,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L296) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301) Flushes Magento Cache. @@ -558,7 +568,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) Magento2 deployment operations. @@ -575,7 +585,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L311) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L316) Magento2 build operations. @@ -588,7 +598,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L317) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L322) Deploys your project. @@ -604,7 +614,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L365) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L370) Packages all relevant files in an artifact. @@ -612,7 +622,7 @@ Packages all relevant files in an artifact. ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L375) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L380) Uploads artifact in release folder for extraction. @@ -620,7 +630,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L380) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) Extracts artifact in release path. @@ -628,7 +638,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L386) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391) Clears generated files prior to building. @@ -636,7 +646,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L396) Prepare local artifact build. @@ -644,7 +654,7 @@ Prepare local artifact build. ### artifact:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L416) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L421) Builds an artifact. @@ -661,15 +671,33 @@ This task is group task which contains next tasks: ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L432) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L437) Adds additional files and dirs to the list of shared files and dirs. +### magento:set_cache_prefix +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L448) + +Update cache id_prefix. + +Update cache id_prefix on deploy so that you are compiling against a fresh cache +Reference Issue: https://github.com/davidalger/capistrano-magento2/issues/151 +use set('use_redis_cache_id') in your deployer script to enable + + +### magento:cleanup_cache_prefix +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L476) + +Cleanup cache id_prefix env files. + +After successful deployment, move the tmp_env.php file to env.php ready for next deployment + + ### artifact:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L439) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L489) Prepares an artifact on the target server. @@ -689,7 +717,7 @@ This task is group task which contains next tasks: ### artifact:finish -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L452) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L502) Executes the tasks after artifact is released. @@ -704,7 +732,7 @@ This task is group task which contains next tasks: ### artifact:deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L460) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) Actually releases the artifact deployment. From e5db359ff009815d3a939f1e59512f4e8b8e39bb Mon Sep 17 00:00:00 2001 From: Tom Scott-Malden Date: Wed, 29 Mar 2023 17:15:41 +0100 Subject: [PATCH 5/7] DD#0000: feat: Updated to use include and Symphony VarExporter --- composer.json | 3 +- composer.lock | 75 +++++++++++++++++++++++++++- docs/recipe/magento2.md | 108 ++++++++++++++++++++-------------------- recipe/magento2.php | 22 +++++--- 4 files changed, 144 insertions(+), 64 deletions(-) diff --git a/composer.json b/composer.json index 4a26ba956..ccf5d749b 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,8 @@ "phpunit/php-code-coverage": "^9.2", "phpunit/phpunit": "^9.3", "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.5" + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-exporter": "^5.4" }, "config": { "sort-packages": true, diff --git a/composer.lock b/composer.lock index 3042e95e4..1a78969ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2e4a876ba583ea7b5ddf4bebd46c0262", + "content-hash": "a8fcdbe293cf508305b9865ac9821da4", "packages": [ { "name": "evenement/evenement", @@ -4775,6 +4775,79 @@ }, "time": "2021-12-12T21:44:58+00:00" }, + { + "name": "symfony/var-exporter", + "version": "v5.4.21", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4", + "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v5.4.21" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-02-21T19:46:44+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index 8a6357853..f9405f686 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -115,7 +115,7 @@ The magento2 recipe is based on the [common](/docs/recipe/common.md) recipe. ## Configuration ### static_content_locales -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L25) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L26) By default setup:static-content:deploy uses `en_US`. To change that, simply put `set('static_content_locales', 'en_US de_DE');` @@ -127,7 +127,7 @@ in you deployer script. ### magento_themes -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L42) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L43) You can also set the themes to run against. By default it'll deploy all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);` @@ -151,14 +151,14 @@ set('magento_themes', [ ### static_deploy_options -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L47) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L48) Static content deployment options, e.g. '--no-parent' ### split_static_deployment -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L50) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L51) Deploy frontend and adminhtml together as default @@ -168,7 +168,7 @@ false ### static_content_locales_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L53) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L54) Use the default languages for the backend as default @@ -178,7 +178,7 @@ Use the default languages for the backend as default ### magento_themes_backend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L57) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L58) backend themes to deploy. Only used if split_static_deployment=true This setting supports the same options/structure as [magento_themes](/docs/recipe/magento2.md#magento_themes) @@ -189,7 +189,7 @@ This setting supports the same options/structure as [magento_themes](/docs/recip ### static_content_jobs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L63) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L64) Also set the number of conccurent jobs to run. The default is 1 Update using: `set('static_content_jobs', '1');` @@ -200,7 +200,7 @@ Update using: `set('static_content_jobs', '1');` ### content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L65) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L66) @@ -210,7 +210,7 @@ return time(); ### magento_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L70) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L71) Magento directory relative to repository root. Use "." (default) if it is not located in a subdirectory @@ -220,7 +220,7 @@ Magento directory relative to repository root. Use "." (default) if it is not lo ### shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L73) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L74) Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`. @@ -235,7 +235,7 @@ Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recip ### shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L77) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78) Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`. @@ -261,7 +261,7 @@ Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/ ### writable_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L93) Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`. @@ -279,7 +279,7 @@ Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `r ### clear_paths -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L99) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L100) Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`. @@ -298,7 +298,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### bin/magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L108) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L109) @@ -308,7 +308,7 @@ Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `re ### magento_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L110) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L111) @@ -321,7 +321,7 @@ return $matches[0] ?? '2.0'; ### config_import_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L117) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L118) :::info Autogenerated @@ -332,7 +332,7 @@ The value of this configuration is autogenerated on access. ### database_upgrade_needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L132) :::info Autogenerated @@ -343,7 +343,7 @@ The value of this configuration is autogenerated on access. ### enable_zerodowntime -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L146) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L147) Deploy without setting maintenance mode if possible @@ -353,7 +353,7 @@ true ### use_redis_cache_id -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L149) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L150) deploy with auto updating cache index_prefix @@ -363,7 +363,7 @@ false ### artifact_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L335) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L336) The file the artifact is saved to @@ -373,7 +373,7 @@ The file the artifact is saved to ### artifact_dir -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L338) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L339) The directory the artifact is saved in @@ -383,7 +383,7 @@ The directory the artifact is saved in ### artifact_excludes_file -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L342) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L343) Points to a file with a list of files to exclude from packaging. The format is as with the `tar --exclude-from=[file]` option @@ -394,7 +394,7 @@ The format is as with the `tar --exclude-from=[file]` option ### build_from_repo -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L345) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L346) If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory @@ -404,7 +404,7 @@ false ### repository -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L348) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L349) Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`. @@ -416,7 +416,7 @@ null ### artifact_path -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L351) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L352) The relative path to the artifact file. If the directory does not exist, it will be created @@ -429,7 +429,7 @@ return get('artifact_dir') . '/' . get('artifact_file'); ### bin/tar -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L359) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L360) The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings :::info Autogenerated @@ -440,14 +440,14 @@ The value of this configuration is autogenerated on access. ### additional_shared_files -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L431) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L432) Array of shared files that will be added to the default shared_files without overriding ### additional_shared_dirs -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L433) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434) Array of shared directories that will be added to the default shared_dirs without overriding @@ -457,7 +457,7 @@ Array of shared directories that will be added to the default shared_dirs withou ## Tasks ### magento:compile -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L159) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L160) Compiles magento di. @@ -469,7 +469,7 @@ e.g. ### magento:deploy:assets -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L185) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L186) Deploys assets. @@ -496,7 +496,7 @@ in `app/etc/config.php`, e.g.: ### magento:deploy:assets:adminhtml -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L201) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L202) Deploys assets for backend only. @@ -504,7 +504,7 @@ Deploys assets for backend only. ### magento:deploy:assets:frontend -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L206) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L207) Deploys assets for frontend only. @@ -512,7 +512,7 @@ Deploys assets for frontend only. ### magento:sync:content_version -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L254) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L255) Syncs content version. @@ -520,7 +520,7 @@ Syncs content version. ### magento:maintenance:enable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L264) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L265) Enables maintenance mode. @@ -528,7 +528,7 @@ Enables maintenance mode. ### magento:maintenance:disable -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L270) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L271) Disables maintenance mode. @@ -536,7 +536,7 @@ Disables maintenance mode. ### magento:maintenance:enable-if-needed -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L276) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L277) Set maintenance mode if needed. @@ -544,7 +544,7 @@ Set maintenance mode if needed. ### magento:config:import -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L283) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L284) Config Import. @@ -552,7 +552,7 @@ Config Import. ### magento:upgrade:db -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L292) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L293) Upgrades magento database. @@ -560,7 +560,7 @@ Upgrades magento database. ### magento:cache:flush -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L302) Flushes Magento Cache. @@ -568,7 +568,7 @@ Flushes Magento Cache. ### deploy:magento -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L306) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L307) Magento2 deployment operations. @@ -585,7 +585,7 @@ This task is group task which contains next tasks: ### magento:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L316) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L317) Magento2 build operations. @@ -598,7 +598,7 @@ This task is group task which contains next tasks: ### deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L322) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L323) Deploys your project. @@ -614,7 +614,7 @@ This task is group task which contains next tasks: ### artifact:package -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L370) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L371) Packages all relevant files in an artifact. @@ -622,7 +622,7 @@ Packages all relevant files in an artifact. ### artifact:upload -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L380) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L381) Uploads artifact in release folder for extraction. @@ -630,7 +630,7 @@ Uploads artifact in release folder for extraction. ### artifact:extract -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L386) Extracts artifact in release path. @@ -638,7 +638,7 @@ Extracts artifact in release path. ### build:remove-generated -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L392) Clears generated files prior to building. @@ -646,7 +646,7 @@ Clears generated files prior to building. ### build:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L396) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L397) Prepare local artifact build. @@ -654,7 +654,7 @@ Prepare local artifact build. ### artifact:build -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L421) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L422) Builds an artifact. @@ -671,7 +671,7 @@ This task is group task which contains next tasks: ### deploy:additional-shared -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L437) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L438) Adds additional files and dirs to the list of shared files and dirs. @@ -679,7 +679,7 @@ Adds additional files and dirs to the list of shared files and dirs. ### magento:set_cache_prefix -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L448) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L449) Update cache id_prefix. @@ -689,7 +689,7 @@ use set('use_redis_cache_id') in your deployer script to enable ### magento:cleanup_cache_prefix -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L476) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L482) Cleanup cache id_prefix env files. @@ -697,7 +697,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### artifact:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L489) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L495) Prepares an artifact on the target server. @@ -717,7 +717,7 @@ This task is group task which contains next tasks: ### artifact:finish -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L502) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L508) Executes the tasks after artifact is released. @@ -732,7 +732,7 @@ This task is group task which contains next tasks: ### artifact:deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L510) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L516) Actually releases the artifact deployment. diff --git a/recipe/magento2.php b/recipe/magento2.php index dd28a1911..685541271 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -8,6 +8,7 @@ use Deployer\Exception\GracefulShutdownException; use Deployer\Exception\RunException; use Deployer\Host\Host; +use Symfony\Component\VarExporter\VarExporter; const CONFIG_IMPORT_NEEDED_EXIT_CODE = 2; const DB_UPDATE_NEEDED_EXIT_CODE = 2; @@ -448,19 +449,24 @@ function magentoDeployAssetsSplit(string $area) task('magento:set_cache_prefix', function () { //get current env config if (get('use_redis_cache_id')) { - $envConfigString = run('cat {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); - $envConfig = eval('?>' . $envConfigString); + //download current env config + $tmpConfigFile = tempnam(sys_get_temp_dir(), 'deployer_config'); + download('{{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH, $tmpConfigFile); + $envConfigArray = include($tmpConfigFile); //set prefix to `alias_releasename_` $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; //update id_prefix to include release name - $envConfig['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; - $envConfig['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; + $envConfigArray['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; + $envConfigArray['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; + //Generate configuration array as string - $envConfigStr = ' {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH); + $envConfigStr = ' Date: Thu, 30 Mar 2023 14:44:59 +0100 Subject: [PATCH 6/7] DD#0000: feat: Updated flag to around the hooks --- recipe/magento2.php | 69 +++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/recipe/magento2.php b/recipe/magento2.php index 685541271..a5cdff40f 100644 --- a/recipe/magento2.php +++ b/recipe/magento2.php @@ -447,48 +447,49 @@ function magentoDeployAssetsSplit(string $area) **/ desc('Update cache id_prefix'); task('magento:set_cache_prefix', function () { - //get current env config - if (get('use_redis_cache_id')) { - //download current env config - $tmpConfigFile = tempnam(sys_get_temp_dir(), 'deployer_config'); - download('{{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH, $tmpConfigFile); - $envConfigArray = include($tmpConfigFile); - //set prefix to `alias_releasename_` - $prefixUpdate = get('alias') . '_' . get('release_name') . '_'; - - //update id_prefix to include release name - $envConfigArray['cache']['frontend']['default']['id_prefix'] = $prefixUpdate; - $envConfigArray['cache']['frontend']['page_cache']['id_prefix'] = $prefixUpdate; - - //Generate configuration array as string - $envConfigStr = ' Date: Thu, 30 Mar 2023 14:46:57 +0100 Subject: [PATCH 7/7] DD#0000: feat: Regen docs --- docs/recipe/magento2.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/recipe/magento2.md b/docs/recipe/magento2.md index f9405f686..4f2247660 100644 --- a/docs/recipe/magento2.md +++ b/docs/recipe/magento2.md @@ -697,7 +697,7 @@ After successful deployment, move the tmp_env.php file to env.php ready for next ### artifact:prepare -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L495) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L496) Prepares an artifact on the target server. @@ -717,7 +717,7 @@ This task is group task which contains next tasks: ### artifact:finish -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L508) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L509) Executes the tasks after artifact is released. @@ -732,7 +732,7 @@ This task is group task which contains next tasks: ### artifact:deploy -[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L516) +[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L517) Actually releases the artifact deployment.