在Elastic Beanstalk上通过.ebextensions安装git

Nic*_*tov 7 git amazon-web-services node.js npm amazon-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.
Run Code Online (Sandbox Code Playgroud)

ddt*_*ler 10

如果您将配置文件放在.ebextensions文件夹中,如下所示:

packages:
  yum:
    git: []
Run Code Online (Sandbox Code Playgroud)

确保git包位于具有更高执行索引的配置文件中,然后实际需要git.将它放在名为的第一个配置文件中是很常见的:00-packages.config.


els*_*sar 3

我可以想到三种方法可以确保在运行git之前在系统上安装(或任何依赖项) 。npm install

  1. 如果需要,请在您的安装中定义一个preinstall脚本。package.jsongit
  2. 您可以使用 pre-appdeploy hooks 目录或 preinit hooks 目录中的 ebextensions添加script(file) 。我建议使用 preinit 挂钩,因为这是安装软件包的挂钩所在的位置。只需将脚本的路径设置为/opt/ebextensions/hooks/preinit/99_install_git.sh,或者如果您想在 pre-appdeploy 中执行操作,/opt/ebextensions/hooks/appdeploy/pre/99_install_git.sh则将 ,并使用该字段使文件可执行mode
  3. 使用 ebextensions安装软件包

对于你的用例,我认为#3 是最好的选择。有点晚了,但希望你觉得有用