I have a node application that requires grunt to do a "build" before the application can be executed successfully. (runs concat/minification/revving of source code etc). I've got this running on an EC2 instance with SSH access as I can just SSH into the directory and run Grunt as part of the deployment process. However to automate this I'm now moving the application to ElasticBeanstalk and I'm having difficulty getting the application to run grunt successfully. The reason for the move to EB is to keep SSH keys OFF live servers so these EB instances are setup with no ssh access.
There seems to be no official documentation available, could anybody point me in a good direction to be able to achieve the above? I need grunt to execute before the application is started so that the application has the files available (otherwise there'll be a 404).
Running grunt would be very similar to running gulp, so, i'll include my config below.
This is inside a .ebextensions folder at the root of my project, named 01run.config. You can have multiple config files, they will run in alphabetical order (hence the 01 at the beginning.)
This basically just instructs the process to run these commands in order, again, it's done in alphabetical order, so I named them accordingly.
commands: 01get_sudo: command: echo Defaults:root \!requiretty >> /etc/sudoers 02npm_install: command: sudo yum -y --enablerepo=epel install nodejs npm 03npm_install_bower: command: sudo npm install -g bower 04npm_install_gulp: command: sudo npm install -g gulp 05yum_install_git: command: sudo yum -y --enablerepo=epel install git container_commands: 01bower_install: command: sudo bower install --allow-root 02gulp_sass: command: sudo gulp sass
In your case, you'd simply remove bower and git installs, install grunt-cli, and then run grunt.
Since doing this, I've removed the need for the above process by doing it all up front before deploying and committing the built files to the git repository. It was at least a good learning experience that gives me much more control over my ec2 instances deployed by beanstalk.