Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: run npm install and gulp build for a Django app

I have a Django app that I managed to deploy with Heroku. My Procfile file only contains :

web: gunicorn omegapp3.wsgi --log-file -

So when I run heroku local it works.

But when I deploy with heroku push master, the console detects a Node app because the app has a package.json and then the build fails.

What I would like to do is the following :

  • run npm install to install gulp etc.
  • run gulp build.

Do you know how I can do that ?

like image 970
rocketer Avatar asked Dec 06 '15 17:12

rocketer


1 Answers

According to the official documentation, you should add multiple buildpacks to your setup, rather than a single multi buildpack.

For example, if you wanted to deploy an app that uses a Nodejs package (i.e. grunt, gulp, etc) to do some setup on your app, you would run this from your command line:

heroku buildpacks:add --index 1 heroku/nodejs

The add command adds the Nodejs buildpack as an additional buildpack, rather than replacing your current buildpack. Note the --index 1. This specifies that the Nodejs buildpack is the first in the order of buildpacks. This is important because the final buildpack is the one used for actual process type. You can call heroku buildpacks from the command line to verify the buildpack setup. I run a Python app, so my heroku buildpacks looks like this:

=== your_app_name_here Buildpack URLs
1. heroku/nodejs
2. https://github.com/heroku/heroku-buildpack-python

Then, as stated by rocketer, you can place this in your package.json file to be run on deploy:

"scripts": {
  "postinstall": "./node_modules/.bin/gulp build"
}
like image 64
J-bob Avatar answered Oct 02 '22 23:10

J-bob