Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento 2 deploy not working with custom magento_dir #3843

Open
yuriy-boyko opened this issue May 30, 2024 · 0 comments
Open

Magento 2 deploy not working with custom magento_dir #3843

yuriy-boyko opened this issue May 30, 2024 · 0 comments

Comments

@yuriy-boyko
Copy link

yuriy-boyko commented May 30, 2024

  • Deployer version: 7.4.0
  • Deployment OS: Ubuntu 22
<?php
namespace Deployer;

require 'recipe/magento2.php';

set('magento_dir', 'src');
set('repository', 'git@github.com:example.git');

add('shared_files', []);
add('shared_dirs', []);
add('writable_dirs', []);

host('dev')
    ->set('hostname', '127.0.0.1')
    ->set('port', 22)
    ->set('remote_user', 'deployer')
    ->set('deploy_path', '~/www');


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

Task deploy:vendors and magento:deploy:assets fails.

The problem:

Task magento:deploy:assets is like this

run("{{bin/php}} {{release_or_current_path}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_deploy_options}} {{static_content_locales}} $themesToCompile -j {{static_content_jobs}}");

Should include somehow magento_dir if set:

run("{{bin/php}} {{release_or_current_path}}/{{magento_dir}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_deploy_options}} {{static_content_locales}} $themesToCompile -j {{static_content_jobs}}");

Same goes for deploy:vendors, the original is:

run('cd {{release_or_current_path}} && {{bin/composer}} {{composer_action}} {{composer_options}} 2>&1');

Correct one should include somehow magento_dir if set:

run('cd {{release_or_current_path}}/{{magento_dir}} && {{bin/composer}} {{composer_action}} {{composer_options}} 2>&1');




To make the deploy.php work anyway, my file starts like this:

<?php
namespace Deployer;

require 'recipe/magento2.php';
//https://deployer.org/docs/7.x/recipe/magento2#repository
// Config


set('magento_dir', 'src');

desc('Installs vendors');
task('deploy:vendors', function () {
    if (!commandExist('unzip')) {
        warning('To speed up composer installation setup "unzip" command with PHP zip extension.');
    }
    run('cd {{release_or_current_path}}/{{magento_dir}} && {{bin/composer}} {{composer_action}} {{composer_options}} 2>&1');
});

desc('Deploys assets');
task('magento:deploy:assets', function () {
    $themesToCompile = '';
    if (get('split_static_deployment')) {
        invoke('magento:deploy:assets:adminhtml');
        invoke('magento:deploy:assets:frontend');
    } else {
        if (count(get('magento_themes')) > 0 ) {
            foreach (get('magento_themes') as $theme) {
                $themesToCompile .= ' -t ' . $theme;
            }
        }
        run("{{bin/php}} {{release_or_current_path}}/{{magento_dir}}/bin/magento setup:static-content:deploy --content-version={{content_version}} {{static_deploy_options}} {{static_content_locales}} $themesToCompile -j {{static_content_jobs}}");
    }
});

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant