Installing git on .ebextensions on an elastic beanstalk

I get an error in Elastic Beanstalk because there is no git in the instance. One of the dependencies in my package. Json depends on the git repository and needs a git clone . Git is not installed on instances. I tried to install it through the .ebextensions.conf file when deploying through yum , but when I ssh into an instance it is not there.

Question: what is the correct installation method and is there git in a Linux instance running on Elastic Beanstalk before npm install is called on that instance?

Here the log shows an error:

 [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. 
+5
source share
2 answers

I can think of three ways to ensure git (or any dependency) security on the system before running npm install .

  • Define a preinstall script in package.json that installs git if necessary.
  • You can add a script (file) using ebextensions in the preload directory or in the preinit hooks directory. I would suggest a preinit hook, like the one where the hook is for installing packages. Just set the path for your script to /opt/ebextensions/hooks/preinit/99_install_git.sh , or if you want to do it in pre-appdeploy, /opt/ebextensions/hooks/appdeploy/pre/99_install_git.sh and make an executable with using the mode field.
  • Use ebextensions to install the package .

For your use case, I think No. 3 is the best option. Scanty, but I hope you find this useful.

+2
source

If you put the configuration file in your .ebextensions folder as follows:

 packages: yum: git: [] 

Make sure the git package is in the configuration file with a higher execution index than the one that git actually requires. This is usually in the first configuration file named: 00-packages.config .

+5
source

All Articles