我有一个Heroku的障碍,我还没有想出最好的解决方法,但也许我错过了一些东西。如何用python(或ruby)和nodejs做heroku?
在我解释更多,让我先说,我所熟悉的Heroku的:
https://github.com/heroku/heroku-buildpack-multi.git
事实上我有一个.buildpacks文件看起来像:
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-python.git
的TL; DR我的问题是,我如何告诉heroku我的nodejs应用程序的基本目录不在根目录中?
如何告诉Heroku应用从我的应用的/ dir1/dir2/ui开始的nodejs buildpack并将该目录用作基目录?但对于Python使用/ dir1作为基本目录?
总的想法是,我将运行某种Python WSGI服务器(无论是Flask还是Django ......或者甚至是Ruby on Rails)。但是我将使用一套节点包来构建我的前端内容(scss文件,JS文件,HTML文件)。
不止一次我使用某种Python starter/seed项目开始一个项目,该项目将生成一个简单的骨架服务器,包含路由和一个简单的Angular前端。
然后,我会尽快使用像yeoman这样的东西来生成一个更丰富和更成熟的前端,它使用节点和吞咽来做各种方便的前端魔术。
然后,我将yeoman UI项目结构合并到我的python项目中,以使用来自Python和node/npm/gulp/bower/Angular的最佳实践来获得完整项目。
合并我一般就会有一个项目结构,看起来像(一些东西,不再赘述)后:
.buildpacks
Procfile
env/ # python virtual environment (not actually checked in to git)
heroku.sh
myproject_dir
models/
views/
ui/
# python templates (eg: *.jinja.html files). i'll predominantly
# be using angular and partials, but I don't totally want to
# give up all server-side templates. SPAs, in reality are not
# usually truly one single-page, but maybe 3 or 4 very rich
# pages
templates/
index.jinja.html # my main html file
# static/ is where the yeoman project really merges in to
# the python project
static/
assets/
images/
foo.jpg
styles/
app.css
partials/
app/
app.html
src/
app/
app.js
test/
test1.js
# gulpfile.js and package.json live in the ui directory (not
# in the static directory), because I actually do want gulp to
# do some processing on my jinja server-side template files
gulpfile.js
package.json
bower.json
node_modules/
bower_components/
manage.py # python top-level for managing script for various things
requirements.txt # python package dependencies
runtime.txt
而且我们现在已经在我的问题与Heroku的到来。
我有2个构建环境,python和node/gulp。但我想告诉heroku我的节点环境从ui /目录开始。
但我还没有想出如何做到这一点。这是可以实现的吗?
我要指出,这个问题的Heroku非常有关:https://github.com/heroku/heroku-buildpack-nodejs/issues/230
目前,它看起来像如果我有我的Python脚本manage.py揭开序幕一饮而尽建立,将无法找到节点和故宫。这可能会导致我的manage.py脚本实际上自行获取并安装node/npm,但这看起来很疯狂。
谢谢!很有帮助。我没有想过Vagrant,只是没有意识到他们有一个图像,调试我的buildpack一直是一个真正的琐事。现在我已经将heroku的python和nodejs构建包合并为一个了,在Python之后运行nodejs。流浪者将会提供帮助。 Docker也很有趣。我从来没有用过它,但听说过它。事实上,Docker可能是Heroku未来的方式。尽管我从来没有用过它,但我认为我更喜欢在buildpack文件上使用Dockerfile。关于buildpack文件和它们运行的环境文件太多没有文档。 – lostdorje
祝你好运! – bwarren2