【问题标题】:CodeDeploy after_install script bug running composer.phar install运行 composer.phar 安装的 CodeDeploy after_install 脚本错误
【发布时间】:2020-10-19 08:22:25
【问题描述】:

我可以在实例上手动运行/opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install,它执行得很好。

我获得了成功的部署(Bitbucket 管道 > Codedeploy > Ec2)但是,我在 /opt/codedeploy-agent/deployment-root/(deployment-group-id)/(deployment-id)logs/scripts.log

2020-10-15 14:47:04 [stderr]  The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly

after_install.sh

#!/bin/bash

# Copy source files to DEVELOPMENT environment
if [ "$DEPLOYMENT_GROUP_NAME" == "staging-deployment-group" ]; then
chown -R user:psacln /var/www/vhosts/example.com/code-deploy-temp
find /var/www/vhosts/example.com/code-deploy-temp -type f -not -name ".pl" -not -name ".cgi" -not -name "*.sh" -print0 | xargs -0 chmod 0644
find /var/www/vhosts/example.com/code-deploy-temp -type d -print0 | xargs -0 chmod 0755
shopt -s dotglob
rsync -avz /var/www/vhosts/example.com/code-deploy-temp/* /var/www/vhosts/example.com/staging.example.com/
rm -rf /var/www/vhosts/example.com/code-deploy-temp/*
cd /var/www/vhosts/example.com/staging.example.com/
/opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install
fi

appspec.yml

version: 0.0
os: linux 
files:
  - source: /
    destination: /var/www/vhosts/example.com/code-deploy-temp
hooks:
  AfterInstall:
    - location: scripts/after_install.sh
      timeout: 300

有人可能有过同样的经历吗?感谢任何输入。

【问题讨论】:

  • 您是否尝试过查看这些环境变量:HOME 或 COMPOSER_HOME?

标签: php amazon-web-services composer-php bitbucket-pipelines aws-code-deploy


【解决方案1】:

通过添加解决此问题:

导出 COMPOSER_HOME="$HOME/.config/composer";

在此行之前 /opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    • 1970-01-01
    • 2016-05-03
    • 2016-11-16
    相关资源
    最近更新 更多