Reputation: 73
I need to install a separate framework that I created inside my node js application running on elastic beanstalk.
I have tried putting scripts inside my main package.json file but I get permission errors when it installs.
So I created a config file and tried running npm install from the container_commands. It didn't want to run npm as it said the command was missing. I tried adding the correct environment path variables to npm, which work when done manually through ssh, but it gave the same error that it couldn't find the npm command.
So finally.
I created a bash script through the ebextension which installs the application and I run that script from the container_commands.
The script gets created correctly but never runs. If I ssh into the instances and execute it manually as sudo it works. The app deploys without erros but it never seems to execute the script, I know this because the node_modules folders are never created.
I'm not sure where to look for errors for this in my logs and when I tried I didn't find anything useful.
Here is my ebextension:
files:
"/tmp/install_application.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
export PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin
eval "cd /var/app/current/library/server && npm install --production"
eval "cd /var/app/current && npm install --production"
container_commands:
00-install-application:
command: "sh /tmp/install_application.sh"
Upvotes: 0
Views: 1968
Reputation: 73
I managed to find the answer to this. I had a few issues with the script.
Here is the final script.
files:
"/opt/elasticbeanstalk/hooks/appdeploy/enact/00-install-application.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin
cd "/tmp/deployment/application/library/server"
npm install --production
Upvotes: 1