jalogut/magento2-deployer-plus

基于deployer.org的Magento 2部署工具

2.8.0 2020-05-04 10:01 UTC

README

Build Status

  • 为Magento 2提供可靠的完全自动化部署工具。
  • 对Magento版本>=2.2实现零停机部署
  • 自动化部署就像定义你想要部署的服务器一样简单。

动机

本项目旨在为所有版本的Magento 2提供一个通用的完全自动化部署解决方案。该工具使用了广为人知的Deployer,并为每个Magento 2版本添加了特定的食谱。

重要功能

  • Deployer代码语法
  • 超级容易设置
  • 部署到多个服务器
  • 零停机(仅限Magento >= 2.2)
  • 构建和部署工件(仅限Magento >= 2.2)
  • 安全的回滚(仅限Magento >= 2.2)

安装

composer require "jalogut/magento2-deployer-plus"

设置

Magento >= 2.1

cp <vendor_dir>/jalogut/magento2-deployer-plus/deploy.php.sample_2_1 deploy.php

Magento >= 2.2

cp <vendor_dir>/jalogut/magento2-deployer-plus/deploy.php.sample_2_2 deploy.php

Magento >= 2.2.5

cp <vendor_dir>/jalogut/magento2-deployer-plus/deploy.php.sample_2_2_5 deploy.php

用法

Git部署

<bin_dir>/dep deploy [<stage>]

构建工件部署:(仅限Magento >= 2.2)

<bin_dir>/dep build
<bin_dir>/dep deploy-artifact [<stage>]

免责声明

构建命令

构建命令只能在配置传播正确配置的情况下使用。请参阅Magento DevDocs

还可以在此处检查app:config:dump问题和解决方案

故障排除

缺少Js翻译(magento版本>=2.1.3 <2.2.1)

  • 问题:在执行多个语言的setup:static-content:deploy时,已知的Magento问题。

  • Github问题:

  • 解决方案:直到在2.2.1中修复,唯一的解决方案是为每种语言单独执行setup:static-content:deploy

     // deploy.php
     task('files:static_assets', '
     	{{bin/php}} {{magento_bin}} setup:static-content:deploy en_US {{static_deploy_options}}
     	{{bin/php}} {{magento_bin}} setup:static-content:deploy de_CH {{static_deploy_options}}
     	{{bin/php}} {{magento_bin}} setup:static-content:deploy fr_FR {{static_deploy_options}}
     ');

编译错误

  • 解决方案:将php的memory_limit配置增加到728M或1024M。

设置新模板时的静态部署错误(如果未使用配置传播)

  • 问题:

    • [LogicException]无法通过指定的键加载主题:'Template'
    • 在文件中未定义@variable
  • 原因:如果设置了新模板,在执行setup:static-content:deploy之前需要先运行setup:upgrade

  • 解决方案:在首次部署新模板时跳过setup:static-content:deploy

    1. 临时禁用任务files:static_assets

      // deploy.php
      task('files:static_assets')->onRoles('Skip');
      
    2. 执行新的发布

    3. 在您的deploy.php文件中启用files:static_assets回退

      • 移除task('files:static_assets')->onRoles('Skip');
    4. 手动执行files:static_assets

      <bin_dir>/dep files:static_assets [<stage>]
      

    之后,未来的部署将没有问题

先决条件

  • PHP >= 7.0.8
  • MAGENTO >= 2.1

变更日志

CHANGELOG.md

开发者

许可

GNU通用公共许可证,版本3(GPLv3)

版权

(c) Juan Alonso juan.jalogut@gmail.com