Heroku与Django和节点构建

时间:2017-05-28 16:46:52

标签: node.js django heroku bitbucket-pipelines

我正在使用Pipelines将所有内容从BitBucket推送到Heroku。问题是静态文件,因为我使用django-gulp,当我调用collectstatic时,它将编译所有sass文件(使用nodejs和gulp)。

首先将代码推送到Heroku并运行它,但事实证明所有其他脚本(pip install,npm install,...)将在BitBucket端执行,而不是Heroku。我的Profile里面有这个:

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

网站正在运行,但没有静态文件。

如果始终使用DISABLE_COLLECTSTATIC=1,则会收到以下内容

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

我需要做的是让Heroku在collectstatic之前首先运行npm install,否则它将无效,但我很难找到相关文档。

heroku local web工作正常,因为我在本地之前运行了collectstatic

bitbucket-pipelines.yml配置:

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

1 个答案:

答案 0 :(得分:0)

解决方案太简单了!

我需要在Heroku上添加另一个nodejs buildpack并且它有效!以下示例

enter image description here