简体   繁体   English

部署策略,PHP + SVN

[英]deployment strategies, PHP + SVN

i just wanna discuss our deployment strategy and find discrepancies in it. 我只想讨论我们的部署策略并找出其中的差异。 the process goes like this 这个过程是这样的

-> Development finishes for a particular release - >特定版本的开发完成

-> All developers commit their files to trunk - >所有开发人员将他们的文件提交到trunk

-> Compare database schemas using TOAD and migrate the changes - >使用TOAD比较数据库模式并迁移更改

-> Create a new branch on SVN - >在SVN上创建一个新分支

-> Export using SVN (to remove .svn folder,etc) - >使用SVN导出(删除.svn文件夹等)

-> minify the JS, CSS - >缩小JS,CSS

-> upload to staging server - >上传到登台服务器

-> perform test cycle - >执行测试周期

-> fix bugs on the branch and verify them - >修复分支上的错误并验证它们

-> re-minify the JS, CSS [if required] - >重新缩小JS,CSS [如果需要]

-> upload to production server - >上传到生产服务器

-> when i say upload, it means uploading files through SSH to /var/www/html folder - >当我说上传时,它意味着通过SSH将文件上传到/ var / www / html文件夹

-> first upload js, css, images - >首先上传js,css,images

-> then upload php files - >然后上传php文件

-> during upload exclude directories like user uploaded pictures, etc. - >上传期间排除目录,如用户上传的图片等。

-> perform test cycle - >执行测试周期

-> fix bugs and upload again (may need re-minify - few files) - >修复bug并再次上传(可能需要重新缩小 - 几个文件)

-> verify bugs - >验证错误

-> verification completes - >验证完成

-> commit branch to svn - >将分支提交到svn

-> merge changes back to the trunk - >将更改合并回主干

-> commit trunk [during this deployment cycle, no one commits any files to the trunk] - > commit trunk [在此部署周期中,没有人将任何文件提交到主干]

the process is really complicated and requires lots of attention. 这个过程非常复杂,需要很多关注。

any suggestions on how we can improve it? 关于如何改进它的任何建议?

I used the following deployment path. 我使用了以下部署路径。 It removes many of your needs to re-upload files to different directories. 它消除了将文件重新上载到不同目录的许多需求。 After initial setup, the most complicated work you will have to do is "svn update" commands in each of your test locations. 初始设置完成后,您需要完成的最复杂的工作是在每个测试位置执行“svn update”命令。

This setup assumes you use config files for pointing to directories like assets, images, and css. 此设置假定您使用配置文件指向资产,图像和css等目录。

  1. Init repository. 初始存储库。 Always have a unique user for production and test checkouts. 始终拥有独特的生产和测试签出用户。 This allows for unique commits from live server back to trunk in emergencies. 这允许在紧急情况下从实时服务器返回到主干的唯一提交。
  2. Devs develop and commit. 开发和承诺。 Builds are tagged with build number, as well as a tag for LIVE when they are supposed to be project ready. 构建标记为内部版本号,以及当它们应该是项目就绪时的LIVE标记。
  3. Checkout is made on test server. 结帐在测试服务器上完成。 If everything goes swell. 如果一切都变得膨胀。 #dev.example.com/~test/project/ #dev.example.com /〜测试/项目/
  4. svn update to a test directory on production server. svn更新到生产服务器上的测试目录。 #example.com/~test/project #example.com /〜测试/项目
  5. svn update to your main project directory on production server to LIVE tag. svn将生产服务器上的主项目目录更新为LIVE标记。 #example.com #example.com
  6. If you have any exceptions in steps 3 through 5, return to step 2. 如果步骤3到5中有任何例外,请返回步骤2。

All projects have a config file, that allows one to set paths to development databases, shared images, etc. config.dist.php works well as a naming schema. 所有项目都有一个配置文件,允许用户设置开发数据库,​​共享图像等路径.config.dist.php很适合作为命名模式。 Each checkout then copies config.dist.php to config.php. 然后每个签出将config.dist.php复制到config.php。 This allows for many configs without SVN collisions. 这允许在没有SVN冲突的情况下进行许多配置。

Each config file typically has some code such as 每个配置文件通常都有一些代码,例如

<?php
    #hopefully, your project can leave these first two constants set to '', because relative paths work for everything
         define('localPath', '/home/www/projectName');
         define('baseURL', 'http://example.com/~projectName');

    #if you want to write everything over a shared filesystem for instance, uploads.
         define('localAssetsDirectory', '/sharedFileSystem/localPath');

    #if you want to include a shared assets directory
         define('assetsURL', 'assets/images');

    #OR if you want to host assets in one location.
         define('assetsURL', 'http://assets.example.com/images/'    
 ?>

All test versions on production and dev server are only accessable by restricted ips, as well as put behind a .htaccess file. 生产和开发服务器上的所有测试版本只能由受限制的ips访问,并且只能放在.htaccess文件后面。 Apache is configured to not serve .svn directories. Apache配置为不提供.svn目录。

if you're using unit testing (eg Selenium) you can use a build tool to script all of this 如果您正在使用单元测试(例如Selenium),您可以使用构建工具编写所有这些脚本

if not, i would just script the following steps: 如果没有,我会编写以下步骤:

  • Export using SVN (to remove .svn folder,etc) 使用SVN导出(删除.svn文件夹等)
  • minify the JS, CSS 缩小JS,CSS
  • upload to staging server 上传到登台服务器

and

  • re-minify the JS, CSS [if required] 重新缩小JS,CSS [如果需要]
  • upload to production server 上传到生产服务器
  • when i say upload, it means uploading files through SSH to /var/www/html folder 当我说上传时,它意味着通过SSH将文件上传到/ var / www / html文件夹
  • first upload js, css, images 首先上传js,css,images
  • then upload php files 然后上传php文件
  • during upload exclude directories like user uploaded pictures, etc. 在上传过程中排除用户上传的图片等目录。

since you're already branching and merging, you should keep your trunk should always be a stable build with the latest features. 因为你已经分支和合并,你应该保持你的主干应该始终是一个具有最新功能的稳定版本。 finally, TAG your releases 最后,标记你的发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM