从 git 部署到生产的最佳解决方案? [英] Best solutions to deploy from git to production?

查看:29
本文介绍了从 git 部署到生产的最佳解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的联合创始人正在为我们的初创公司设置服务器.我们使用 git 进行源代码控制,项目是 django,通过 Ubuntu 上的 fcgi 位于 nginx 后面.由于我们才刚刚开始,为了让我们双方都能轻松部署,我想在服务器上安装一个简单的部署脚本,它会自动从 git 中提取最新的代码更改,然后部署它们.

My cofounder and I are setting up our server for our startup. We're using git for our source control and the project is django sitting behind nginx via fcgi on Ubuntu. Since we're just getting started, and to make deployments easy on both of us, I have in mind to have a simple deploy script living on the server that will automatically pull in the latest code changes from git and then deploy them.

我知道我可以手动编写一个 bash 或 python 脚本来执行此操作,但我希望首先找出是否有其他相对易于使用的软件解决方案可以使用.在这个阶段,我们对持续部署还没有什么兴趣,但我认为该领域中可能有一些对我们有用的包.

I know I can manually write a bash or python script that will do this, but I was hoping to first find out if there are other relatively easy to use software solutions that I can just tie into. At this stage, we have little interest in continuous deploy yet but I'm thinking there might be some packages in that domain that could be useful to us.

推荐答案

有几个选择:

  1. 在要推送到的服务器上托管一个 git 存储库,它会自动检查最新版本.更多关于这里,也请查看这个 分离的 git 树 解决方案也是如此.

  1. Hosting a git repository on the server to push to, which automagically checks out the latest version. More on this here, also check out this detached git tree solution, too.

fabric 之类的内容与 rsync 或类似内容一起使用.

Use something like fabric with rsync or similar.

通常,我会有一个内联 git 仓库,其中包含针对特定分支(通常是实时")的更新后挂钩设置.然后是我的笔记本电脑上的 git remote add -t live live ssh://...git push live 来推送东西的问题.您还需要一些东西来重新启动 Django 服务器以使新代码生效(可以在钩子或 ssh/fabric 中执行此操作).

Typically I would have an inline git repo with the post-update hook setup for a specific branch (usually "live"). Then it's a matter of git remote add -t live live ssh://... on my laptop and a git push live to get things pushed. You'll also need something to restart the Django server for the new code to take effect (could do this inside the hook, or ssh/fabric).

对于未来的项目,我正在尝试将分离的 git 树(看起来更优雅)与结构相结合.

For future projects, I'm experimenting with the detached git tree (seems more elegant) combined with fabric.

这篇关于从 git 部署到生产的最佳解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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