Sunday 28 May 2017

Heroku with Django and node build

I am pushing everything from BitBucket to Heroku, using Pipelines. The problem are static files because I am using django-gulp which will compile all sass files (using nodejs and gulp) when I call collectstatic.

It will first push code to Heroku and run it, but as it turns out all other scripts (pip install, npm install, ...) will execute on BitBucket side, and not Heroku. My Profile has this inside:

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

Website is running, but there are no static files.

If always run with DISABLE_COLLECTSTATIC=1, otherwise I get the following

remote: -----> $ python manage.py collectstatic --noinput        
remote:        /bin/sh: 1: gulp: not found 

What I would need to do is for Heroku to first run npm install before collectstatic or it won't work, but I am having hard time finding any documentation on this.

heroku local web works fine, because I ran collectstatic before locally.


bitbucket-pipelines.yml configuration:

image: nikolaik/python-nodejs

pipelines:
  default:
    - step:
        script:
          - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
          - pip install -r requirements.txt
          - npm install
          - npm install -g gulp
          - python manage.py collectstatic --noinput



via Bojan Kogoj

No comments:

Post a Comment