我想部署一个PHP网站使用Capistrano。该网站由4个组件(前端代码和3个Web服务)组成,每个组件都存储在它自己的git存储库中。我想将所有4个组件部署到一个树形结构中(见下文),因此网站版本之间的切换将与移动“当前”链接一样简单。将多个应用程序部署到与Capistrano和Git的单一树
我看到,默认情况下,Capistrano部署旨在部署单个存储库。如果我理解正确,即使使用诸如Caphub之类的东西也不会对我有所帮助,因为4个组件将部署到4个不同的树中,使得回滚到特定时间点成为一个繁琐的过程。
有没有办法使用Capistrano获得下面的配置?这种情况的最佳做法是什么?
root/
| current/
| releases/
| | <timestamp/>
| | | frontend/
| | | webservice-1/
| | | webservice-2/
| | | webservice-3/
| | <timestamp/>
| | | frontend/
| | | webservice-1/
| | | webservice-2/
| | | webservice-3/
| shared/
更新:
彼时使用子模块的解决方案,如接受的答案建议。我创建了一个拥有4个子模块和一个网站部署库的网站仓库,我保留了capistrano部署文件。我写了一个简单的shell脚本来为我节省每次部署时更新子模块的麻烦(一个非常繁琐的过程!)。部署我运行脚本(源代码下面),然后运行“帽部署”。
#!/bin/sh
git clone gitserver:path_to_git_repositories/website.git cloned
cd cloned
git submodule init
git submodule update
git submodule foreach git pull origin master # updating all modules to the current code in the master branch
git submodule foreach git add .
git commit -a -m "Updating submodules"
git push origin master
cd ..
rm -rf cloned
有一种新的方法。请参阅此答案http://stackoverflow.com/a/40921589/2067375。 (免责声明:我是宝石的拥有者) – 2016-12-01 22:38:47