Using Grunt or Gulp with OpsWorks

I would like to run Grunt or Gulp when deploying an application to Amazon OpsWorks. By default, the Node.js OpsWorks layer runs npm install but not gulp, and I don't know how to write my own recipes: is there any other solution?

+3


source to share


2 answers


No, you need to write a recipe.

Even the Node.js OpsWorks layer installs npm via the recipe:

opsworks-cookbooks / deploy / recipes / nodejs.rb ( https://github.com/aws/opsworks-cookbooks/blob/master-chef-11.10/deploy/recipes/nodejs.rb#L20 for chef 11.10), which reads:

opsworks_nodejs do
    deploy_data deploy
    app application
end

      



which is defined in:

opsworks-cookbooks / deploy / definitions / opsworks_nodejs.rb ( https://github.com/aws/opsworks-cookbooks/blob/master-chef-11.10/deploy/definitions/opsworks_nodejs.rb#L9 for chef 11.10) and does:

node[:dependencies][:npms].each do |npm, version|
    execute "/usr/local/bin/npm install #{npm}" do
        cwd "#{deploy[:deploy_to]}/current"
    end
end

      

+2


source


An alternative is for Gulp to appear from a file that OpsWorks expects, i.e. server.js

:

var child_process = require( "child_process" );
child_process.spawn( "./node_modules/gulp/bin/gulp.js", 
  [ "main" ].concat( process.argv.slice( 2 ) ), {
    stdio: "inherit"
  }
);

      



and then run the real main file (for example index.js

) from Gulp.

0


source







All Articles