使用 git 进行部署
目前,我有一堆用于我要部署的 django 站点的 git 存储库,存储库的形式如下:
sn-static
sn-django
sn-templates
[etc]
然后我有一个 超级 存储库,将每个存储库存储为子模块。在部署方面,我想尝试让事情变得相当简单,这是否是一种有效的方法:
- 从超级存储库克隆一个稳定的标签?因此,每个存储库的稳定克隆都放在一个地方。
- 由于名称是 sn-* 我会查看符号链接到更友好的结构,例如 ln -s /path/to/super-repos/sn-static /home/site/media/
- 然后我的nginx 网络服务器(至少在静态内容的情况下)可以简单地引用 /home/site/media
如果没有大量的技术知识,我不确定符号链接是否会在速度或稳定性方面产生任何影响。我还想知道我是否可以将此作为一种部署方法,而不是使用像 Capistrano 这样的东西(到目前为止我还没有经验)。
Currently I have a bunch of git repos for a django site i'm looking to deploy, the repos' take the form:
sn-static
sn-django
sn-templates
[etc]
I then have a super repos that stores each of these as a submodules. In terms of deployment, I want to try to keep things fairly simple, would it be a valid method to:
- Clone a stable tag from the super repos & therefore have stable clones of each repos in one place.
- As the names are sn-* I would then look the symlink to a more friendly structure e.g.
ln -s /path/to/super-repos/sn-static /home/site/media/
- Then my nginx webserver (in the case of static content at least) could simply refer to /home/site/media
Without a great deal of technical knowledge i'm unsure if symlinking would have any implications, in terms of speed or stability. I'm also wondering if I can get away with this as a method of deployment, rather than, say, using something like Capistrano (that as yet I have no experience with).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该考虑的一个选项是将
pip
与virtualenv
来安装你的包,特别是 pip 可以选择 直接从 git 存储库安装某些分支或标签。这样,您就可以使用一个需求文件来处理您的所有依赖项、您自己的软件包和其他人的应用程序。 (参见这篇文章了解大局。)
为了处理静态媒体,我更喜欢使用 Django 的内置 静态文件应用 而不是符号链接多个目录,因为它看起来更干净且更易于管理。
An option you should consider is using
pip
in conjunction withvirtualenv
to install your packages especially as pip has the option to directly install certain branches or tags from a git repository.That way you can use one requirements file to handle all your dependencies, your own packages and apps by other people. (See this post for the big picture.)
And to handle your static media I'd prefer to use Django's builtin staticfiles app instead of symlinking several dirs, as it seems cleaner and easier to manage.
当您到达代码中的发布点时,对其进行标记 (Git 标记)。在您的服务器上,克隆一次主分支,然后在每次发布时简单地拉取您想要的发布标签。
When you reach a release point in your code, tag it (Git Tag). On your server, clone the master branch once and then simply to pull the release tag you want, each time you do a release.