在 Elastic Beanstalk 上通过 .ebextensions 安装 git
Installing git through .ebextensions on Elastic Beanstalk
我在部署到 Elastic Beanstalk 时遇到错误,因为实例上没有 git。我的 package.json 中的依赖项之一依赖于 git 存储库,需要 git clone
。
Git 未安装在实例上。我尝试在部署时通过 .ebextensions .conf 文件安装它,通过 yum
,但是当我 ssh 进入实例时它不存在。
问题是:在 npm install
之前在 Elastic Beanstalk 上的 Linux 实例 运行 上安装和拥有 git 的正确方法是什么调用那个实例?
这是显示错误的日志:
[2015-04-18T09:00:02.815Z] ERROR [1777] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
npm WARN package.json amity-api-v2@2.0.0 No repository field.
npm WARN package.json amity-api-v2@2.0.0 No README data
npm WARN `git config --get remote.origin.url` returned wrong result (https://github.com/awslabs/dynamodb-document-js-sdk) undefined
npm WARN `git config --get remote.origin.url` returned wrong result (https://github.com/awslabs/dynamodb-document-js-sdk) undefined
npm ERR! git clone https://github.com/awslabs/dynamodb-document-js-sdk undefined
npm ERR! git clone https://github.com/awslabs/dynamodb-document-js-sdk undefined
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v0.12.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.12.0-linux-x64/bin/npm" "--production" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ENOGIT
npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.
我可以想到三种方法来确保 git
(或任何依赖项)在 npm install
成为 运行 之前安装在系统上。
- 在
package.json
中定义一个 preinstall
脚本,如果需要,它会安装 git
。
- 您可以添加一个 script(file),在 pre-appdeploy hooks 目录或 preinit hooks 目录中使用 ebextensions。我建议使用 preinit 挂钩,因为这是安装包的挂钩所在。只需将脚本的路径设置为
/opt/ebextensions/hooks/preinit/99_install_git.sh
,或者如果您想在应用程序部署前执行 /opt/ebextensions/hooks/appdeploy/pre/99_install_git.sh
,并使用 mode
字段使文件可执行。
- 使用 ebextensions install a package。
对于您的用例,我认为 #3 是最佳选择。有点晚了,但我希望你觉得它有用
如果像这样将配置文件放在 .ebextensions 文件夹中:
packages:
yum:
git: []
确保 git 包位于执行索引高于实际需要 git 的配置文件中。通常将它放在名为:00-packages.config
.
的第一个配置文件中
我在部署到 Elastic Beanstalk 时遇到错误,因为实例上没有 git。我的 package.json 中的依赖项之一依赖于 git 存储库,需要 git clone
。
Git 未安装在实例上。我尝试在部署时通过 .ebextensions .conf 文件安装它,通过 yum
,但是当我 ssh 进入实例时它不存在。
问题是:在 npm install
之前在 Elastic Beanstalk 上的 Linux 实例 运行 上安装和拥有 git 的正确方法是什么调用那个实例?
这是显示错误的日志:
[2015-04-18T09:00:02.815Z] ERROR [1777] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
npm WARN package.json amity-api-v2@2.0.0 No repository field.
npm WARN package.json amity-api-v2@2.0.0 No README data
npm WARN `git config --get remote.origin.url` returned wrong result (https://github.com/awslabs/dynamodb-document-js-sdk) undefined
npm WARN `git config --get remote.origin.url` returned wrong result (https://github.com/awslabs/dynamodb-document-js-sdk) undefined
npm ERR! git clone https://github.com/awslabs/dynamodb-document-js-sdk undefined
npm ERR! git clone https://github.com/awslabs/dynamodb-document-js-sdk undefined
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v0.12.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.12.0-linux-x64/bin/npm" "--production" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ENOGIT
npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.
我可以想到三种方法来确保 git
(或任何依赖项)在 npm install
成为 运行 之前安装在系统上。
- 在
package.json
中定义一个preinstall
脚本,如果需要,它会安装git
。 - 您可以添加一个 script(file),在 pre-appdeploy hooks 目录或 preinit hooks 目录中使用 ebextensions。我建议使用 preinit 挂钩,因为这是安装包的挂钩所在。只需将脚本的路径设置为
/opt/ebextensions/hooks/preinit/99_install_git.sh
,或者如果您想在应用程序部署前执行/opt/ebextensions/hooks/appdeploy/pre/99_install_git.sh
,并使用mode
字段使文件可执行。 - 使用 ebextensions install a package。
对于您的用例,我认为 #3 是最佳选择。有点晚了,但我希望你觉得它有用
如果像这样将配置文件放在 .ebextensions 文件夹中:
packages:
yum:
git: []
确保 git 包位于执行索引高于实际需要 git 的配置文件中。通常将它放在名为:00-packages.config
.