deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box

Home Page:https://deployer.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Magento 2, ofthen a second deploy needed to work without errors

Aquive opened this issue · comments

  • Deployer version: 7.3.1
  • Deployment OS: Ubuntu 22.04

Very often we need to do a second deploy to make magento 2 working again after a first "succesfull" deploy. (The deploy is succesfull but Magento throws an erros, see below). I am not exactly sure when this problem occurs but I think it happens when enabling a previously disabled module.

This time it was this error. The CSP module was disabled, and with this deploy it was being enabled.

There has been an error processing your request
Warning: Undefined array key "policy_id"
in /vendor/magento/module-csp/Model/Collector/ConfigCollector.php on line 111

Deploy.php

<?php
namespace Deployer;

require 'recipe/magento2.php';

// Config

set('repository', '<repo url>');
set('update_code_strategy', 'clone');
set('writable_mode', 'chmod');
set('keep_releases', 3);

add('shared_files', []);
add('shared_dirs', [
    'pub/feeds',
    'pub/blog',
    'pub/sitemaps'
]);
add('writable_dirs', []);

// Languages
set('static_content_locales', 'nl_NL');
set('magento_themes', [
    'Aqm/Luma',
    ]);
set('magento_themes_backend', ['Magento/backend']);
set('static_deploy_options', '--no-parent');
set('static_content_locales_backend', 'en_US nl_NL');
set('split_static_deployment', true);

// Hosts
host('production')
    ->set('hostname', '<host>')
    ->set('remote_user', 'app')
    ->set('deploy_path', '<path>');

// Hooks

after('deploy:failed', 'deploy:unlock');

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

Is in this case the module already in config.php as enabled or isn't it in the config.php and enables setup:upgrade it on deploy?

Hey @peterjaap thanks for your fast reply. It is deployed after running/testing/commiting everything locally. So the module is present in config.php with a 1 (enabled) like below.

'Magento_Csp' => 1,

This is just an example. We experience sometimes a second deploy is needed. I am not sure if it is allways when enabling a module. It might be the case in other situations too. I will pay attention and check it from now on.