部署策略,PHP + SVN

发布于 2024-10-03 18:26:56 字数 722 浏览 2 评论 0原文

我只是想讨论我们的部署策略并找出其中的差异。过程是这样的

->特定版本的开发完成

->所有开发人员将他们的文件提交到主干

->使用 TOAD 比较数据库模式并迁移更改

->在SVN上创建一个新分支

->使用 SVN 导出(删除 .svn 文件夹等)

->缩小 JS、CSS

->上传到临时服务器

->执行测试循环

->修复分支上的错误并验证它们

->重新缩小 JS、CSS [如果需要]

->上传到生产服务器

->当我说上传时,意思是通过 SSH 将文件上传到 /var/www/html 文件夹

->首先上传js、css、图片

->然后上传php文件

->上传期间排除用户上传的图片等目录

->执行测试循环

->修复错误并再次上传(可能需要重新缩小 - 几个文件)

->验证错误

->验证完成

->将分支提交到 svn

->将更改合并回主干

-> commit trunk [在这个部署周期中,没有人向 trunk 提交任何文件]

这个过程非常复杂,需要大量的关注。

关于如何改进它有什么建议吗?

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

-> Compare database schemas using TOAD and migrate the changes

-> Create a new branch on SVN

-> Export using SVN (to remove .svn folder,etc)

-> minify the JS, CSS

-> upload to staging server

-> perform test cycle

-> fix bugs on the branch and verify them

-> re-minify the JS, CSS [if required]

-> upload to production server

-> when i say upload, it means uploading files through SSH to
/var/www/html folder

-> first upload js, css, images

-> then upload php files

-> during upload exclude directories like user uploaded pictures, etc.

-> perform test cycle

-> fix bugs and upload again (may need re-minify - few files)

-> verify bugs

-> verification completes

-> commit branch to svn

-> merge changes back to the trunk

-> commit trunk [during this deployment cycle, no one commits any files to the trunk]

the process is really complicated and requires lots of attention.

any suggestions on how we can improve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┾廆蒐ゝ 2024-10-10 18:26:56

我使用了以下部署路径。它消除了您将文件重新上传到不同目录的许多需要。初始设置后,您需要做的最复杂的工作是每个测试位置中的“svn update”命令。

此设置假设您使用配置文件来指向资产、图像和 css 等目录。

  1. 初始化存储库。始终有一个唯一的用户进行生产和测试检查。这允许在紧急情况下从实时服务器返回到主干的独特提交。
  2. 开发人员开发并提交。构建版本带有构建号标记,以及当它们应该准备好项目时的 LIVE 标记。
  3. 结帐是在测试服务器上进行的。如果一切顺利的话。 #dev.example.com/~test/project/
  4. svn 更新到生产服务器上的测试目录。 #example.com/~test/project
  5. svn 将生产服务器上的主项目目录更新为 LIVE 标签。 #example.com
  6. 如果您在步骤 3 到 5 中遇到任何异常,请返回到步骤 2。

所有项目都有一个配置文件,允许设置开发数据库、共享图像等的路径。config.dist.php 效果很好命名模式。每次签出都会将 config.dist.php 复制到 config.php。这允许许多配置而不会发生 SVN 冲突。

每个配置文件通常都有一些代码,例如

<?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/'    
 ?>

生产和开发服务器上的所有测试版本只能通过受限制的 ip 访问,并放在 .htaccess 文件后面。 Apache 配置为不提供 .svn 目录服务。

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.

This setup assumes you use config files for pointing to directories like assets, images, and 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.
  3. Checkout is made on test server. If everything goes swell. #dev.example.com/~test/project/
  4. svn update to a test directory on production server. #example.com/~test/project
  5. svn update to your main project directory on production server to LIVE tag. #example.com
  6. If you have any exceptions in steps 3 through 5, return to step 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. Each checkout then copies config.dist.php to config.php. This allows for many configs without SVN collisions.

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. Apache is configured to not serve .svn directories.

酸甜透明夹心 2024-10-10 18:26:56

如果您正在使用单元测试(例如 Selenium),您可以使用构建工具来编写所有这些脚本,

如果没有,我只需编写以下步骤的脚本:

  • 使用 SVN 导出(以删除 .svn 文件夹等)
  • 缩小 JS、CSS
  • 上传到临时服务器

  • 重新压缩 JS、CSS [如果需要]
  • 上传到生产服务器
  • 当我说上传时,这意味着通过 SSH 将文件上传到 /var/www/html 文件夹,
  • 首先上传 js、css、图像,
  • 然后上传 php 文件
  • 在上传过程中排除用户上传的图片等目录。

因为您已经在分支和合并,所以您应该保持主干始终是具有最新功能的稳定版本。
最后,标记您的版本

if you're using unit testing (e.g. Selenium) you can use a build tool to script all of this

if not, i would just script the following steps:

  • Export using SVN (to remove .svn folder,etc)
  • minify the JS, CSS
  • upload to staging server

and

  • re-minify the JS, CSS [if required]
  • upload to production server
  • when i say upload, it means uploading files through SSH to /var/www/html folder
  • first upload js, css, images
  • then upload php files
  • 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文