rocketer
rocketer

Reputation: 1071

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 :

Do you know how I can do that ?

Upvotes: 5

Views: 1383

Answers (2)

J-bob
J-bob

Reputation: 9106

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"
}

Upvotes: 6

rocketer
rocketer

Reputation: 1071

Solved by using $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git.
It allows to use node and python (you have to specify in a .buildpacks file). In ordre to run gulp build, I added the following to my package.json :

"scripts": {
  "postinstall": "./node_modules/.bin/gulp build"
}

Upvotes: 1

Related Questions