【问题标题】:Application structure and workflow with heroku, flask and yeomanHeroku、Flask 和 yeoman 的应用程序结构和工作流程
【发布时间】:2013-12-18 07:50:48
【问题描述】:

我构建了一个简单的 Web 应用程序 AngularJS 和 Flask(REST 架构)。我正在使用 yeoman 生成所有样板文件。问题在于需要通过 git 部署的 heroku 托管。项目结构:

client <- content generated by yeoman
server
|-- static
|-- venv
server.py <- flask
Procfile
.gitifnore
...

我修改了 grunt 脚本,所以最后 dist 文件夹被复制到静态。目前dist 在.gitignore 中,但我正在考虑一些可能的解决方案

  1. 用于部署的单独存储库
  2. 致力于每个构建
  3. 基于 Heroku 构建

每个人都有优点和缺点(不知道 3. 是否可能)。有没有更好的办法?

编辑:

这是当前的事态。将dist 客户端复制到heroku\static,现在我手动复制服务器。但我不确定如何将它推送到heroku。 git subtree push --prefix heroku heroku master 给了我被拒绝的消息。我设置了遥控器并尝试了所有组合,但到目前为止没有成功。

.git 
.gitignore
README.md
client
heroku
   .git
   static
   Procfile
   requriements.txt 
server

【问题讨论】:

    标签: git heroku flask gruntjs yeoman


    【解决方案1】:

    我最终拥有单独的 repo 并使用调用来管理它。这是构建脚本。

    from invoke import run, task
    
    @task
    def clean():
      run("rm -rf heroku/*")
      run("cd client && grunt clean")
    
    @task
    def build():
      run("cd client && grunt")
    
    @task
    def deploy():
      run("mkdir heroku/static && cp -r client/dist/* heroku/static/")
      run("rsync -av --exclude='venv' --exclude='local_server.py' server/ heroku")
      msg = run("git log -1 --pretty=%B").stdout
      run("cd heroku && git add --all && git commit -m '%s' && git push heroku master" % (msg,))
    
    @task("clean", "build", "deploy")
    def all():
      pass
    

    【讨论】:

      【解决方案2】:

      至于第一个选项:查看this SO 线程 - 基本上使用 git-subtree,您可以拥有一个单独的构建仓库,并避免生产提交污染开发仓库。
      因为这个第二个选项没有意义。

      【讨论】:

      • 我知道子树,但我希望有更好的方法。我现在正在与“推送被拒绝,无法删除主分支”作斗争
      • 这是一个常见的 Heroku 相关问题。继续挖掘':)
      猜你喜欢
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 2012-02-05
      • 2020-02-20
      • 2012-09-12
      • 1970-01-01
      • 2015-03-05
      • 1970-01-01
      相关资源
      最近更新 更多