Heroku + Github部署策略 [英] Heroku + Github deployment strategies

查看:206
本文介绍了Heroku + Github部署策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网络应用程序,在Github上托管源代码并在Heroku上运行应用程序。一切工作正常,但我有问题,我不能包裹我的头。在部署我的代码之前,我运行一些脚本来优化代码(缩小,连接文件等)。这个heroku应用程序只使用应用程序的优化版本。基本上,我有两个文件夹: dev 生产 Dev 包含我编写的源代码, production 是由我的构建脚本(我使用grunt和requirejs)生成的。目前,这两个文件夹都在我的Git仓库中,并且都被推送到Github和Heroku。我更喜欢在Github上只有 dev ,在Heroku上只有 production
我阅读了一些文章,了解如何为Heroku设置不同的分支,如。我可以设置一个生产分支,只有生产文件夹在那里,同时保持 dev 文件夹到我的主分支?或者我需要单独的存储库?



有没有人试过类似的东西?我会认为这不是一般的事情。

解决方案

您可能只想考虑使用heroku .slugignore 文件(参考 https://devcenter.heroku.com/articles/slug-compiler )。

该文件允许您从heroku部署到每个服务器实例的软件包中删除 dev 文件夹,同时允许您将所有代码保留在同一个存储库中。



问题的根源在于将部署策略作为将最终位上传到服务器的部署策略,其中<这些位是构建您的存储库的人造物。在这种情况下,版本通常会与源分开存储和归档。

Heroku的模型与此略有不同,因为它假设您的存储库是部署的制造品。这种差异很小,但就您而言,这意味着您需要向您的存储库提交您希望heroku服务的位。



另一种思考方式你可以不用你的 production 文件夹,并且作为启动服务器的一部分,脚本将运行以生成 production 文件夹文件。这将允许您删除生产文件夹,并保持您的存储库清洁,但需要在每次启动服务器时运行此过程。这可能证明是非常昂贵和不受欢迎的(Heroku在启动之前等待服务器启动的时间有限),但希望有助于提供关于Heroku和git关系的一些清晰度。


I am working on a web app, hosting the source code on Github and running the app on Heroku. Everything works fine, but I have on issue I can't wrap my head around. Before the deploying my code, I run some scripts to optimize the code (minifying, concatenating files etc.). The heroku app only uses the optimized version of the app.

Basically, I have two folders: dev and production. Dev contains the source code I write, production is produced by my build scripts (I use grunt and requirejs). Currently, both folders are in my Git repository and both are pushed to Github and Heroku. What I'd rather like is to only have dev on Github and only production on Heroku. I read some articles how to setup different branches for Heroku, as described in this blog. Could I setup a production branch and only have the production folder in there while keeping the dev folder to my master branch? Or would I need separate repositories?

Has anyone tried something similar? I would assume that this is not something out of the ordinary.

解决方案

You may want to simply consider using the heroku .slugignore file (ref https://devcenter.heroku.com/articles/slug-compiler).

This file would allow you remove the dev folder from the package that heroku deploys to each server instance, while allowing you to keep all your code in the same repository.

The root of the problem is thinking about the deployment strategy as one where you upload final bits to your server, where the bits are an artefact of building your repository. In such cases, builds are usually stored and archived separately from the source.

Heroku's model is slightly different from this in that it assumes your repository is the artefact to deploy. The difference is slight, but in your case, it just means that you need to commit to your repository the bits you want heroku to serve.

Another way of thinking about it is that you could do without your production folder, and as part of starting your server, the script would be run to generate the production folder files. This would allow you to remove the production folder, and keep your repository clean at the cost of running this process on every start of your server. This may prove to be prohibitively expensive and undesirable (there are limits to how long Heroku will wait for a server to startup before it gives up on it), but hopefully helps in providing some clarity around the Heroku and git relationship.

这篇关于Heroku + Github部署策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆