简体   繁体   English

2 台云服务器,1 台开发,1 台产品; 什么是好的部署过程?

[英]2 cloud servers, one dev, one prod; what's a good deployment process?

Currently using LAMP stack for my web app.目前为我的 web 应用程序使用 LAMP 堆栈。 My dev and prod are in the same cloud instance.我的 dev 和 prod 在同一个云实例中。 Now I am getting a new instance and would like to move the dev/test environment to the new instance, separating it from the prod environment.现在我得到一个新实例,并希望将开发/测试环境移动到新实例,将其与生产环境分开。

It used to be a simple Phing script that would do a SVN export into the prod directory (pointed to by my vhost.conf).它曾经是一个简单的 Phing 脚本,可以将 SVN 导出到 prod 目录(由我的 vhost.conf 指向)。 How do I make a good build process now with the environments separated?现在如何在环境分离的情况下进行良好的构建过程?

Thinking of transferring the SVN repository to the dev server and then doing a ssh+svn push (is this possible with Phing?)考虑将 SVN 存储库转移到开发服务器,然后进行 ssh+svn 推送(这可以通过 Phing 实现吗?)

What's the best/common practice for this type of setup?这种设置的最佳/常见做法是什么?

More Info:更多信息:

I'm currently using CodeIgniter for MVC framework, Phing for automated builds for localhost deployment.我目前正在将CodeIgniter用于 MVC 框架,将Phing用于 localhost 部署的自动构建。 The web app is also supported by a few CRON scripts written in Java . web 应用程序也得到了一些用Java编写的 CRON 脚本的支持。

Update:更新:

Ended up using Phing + Jenkins.最终使用 Phing + Jenkins。 Working well so far!到目前为止工作良好!

We use Phing for doing deployments similar to what you have described.我们使用 Phing 进行类似于您所描述的部署。 We also use Symfony framework for our projects (which is not so much important for this but Symfony supports the concept of different environments so it's a plus).我们还为我们的项目使用 Symfony 框架(这对此并不重要,但 Symfony 支持不同环境的概念,所以这是一个优点)。

However we still need to produce different configuration files for database, front controllers etc.但是我们仍然需要为数据库、前端控制器等生成不同的配置文件。

So we ended up having a folder with build.properties that define configuration for different environments (and in our case also for different clients we ship our product to).所以我们最终得到了一个包含 build.properties 的文件夹,它定义了不同环境的配置(在我们的例子中,也适用于我们将产品运送到的不同客户)。 This folder is linked to the file structure using svn externals (again not necessary).此文件夹使用 svn 外部链接到文件结构(同样不是必需的)。

The Phing build.xml file then accept a property file as a parameter on the command line, takes the values from it and produces all necessary configuration files, controllers and other environment specific files. Phing build.xml 文件然后在命令行上接受一个属性文件作为参数,从中获取值并生成所有必要的配置文件、控制器和其他环境特定文件。 We store the configuration in template files and then use copy/filter feature in Phing to replace the placeholders in the templates with the specific values.我们将配置存储在模板文件中,然后使用 Phing 中的复制/过滤功能将模板中的占位符替换为特定值。

The whole task of configuring the given environment can then be as simple as something like this:配置给定环境的整个任务可以像这样简单:

phing configure-environment -DpropertyFile=./build_properties/build.properties.prod

In your build file you check if the propertyFile property that specifies the properties file is defined and load the file using <property file="./build_properties/build.properties.prod" override="true" /> .在您的构建文件中,您检查是否定义了指定属性文件的propertyFile属性并使用<property file="./build_properties/build.properties.prod" override="true" />加载文件。 Then you just do any magic with the values as you need.然后,您只需根据需要对值进行任何魔术。

You can still use your svn checkout/update and put all the resulting configuration files into svn ignore (you will have them generated by phing).您仍然可以使用 svn 检出/更新并将所有生成的配置文件放入 svn 忽略(您将通过 phing 生成它们)。 We actually use additional steps in Phing.我们实际上在 Phing 中使用了额外的步骤。 Those steps in the end produce a Linux shell installation self-deploy package.这些步骤最终产生了 Linux shell 安装自部署 package。 This is produced automatically in Jenkins.这是在 Jenkins 中自动生成的。 We then send the package to our clients or the support team can grab the package from Jenkins and they can do the whole deployment just by executing it (we still prefer manual deployments to production servers) or Jenkins can deploy it automatically (for example to test servers). We then send the package to our clients or the support team can grab the package from Jenkins and they can do the whole deployment just by executing it (we still prefer manual deployments to production servers) or Jenkins can deploy it automatically (for example to test服务器)。

I'll be happy to write more info if needed.如果需要,我很乐意写更多信息。

I recommend using Capistrano (looks like they haven't updated the docs since they moved the site) and railsless-deploy for doing deployment.我建议使用Capistrano (看起来他们在移动站点后没有更新文档)和railsless-deploy进行部署。 Eventually, you are probably going to need to add more app boxes and run other tasks as part of your deployment so choosing a framework that will support this can save you a lot of time in the future.最终,您可能需要添加更多应用程序框并运行其他任务作为部署的一部分,因此选择支持此功能的框架可以在未来为您节省大量时间。 I have used capistrano for two PHP deployments (one small and one large) and although its not perfect, it works well.我已经将 capistrano 用于两个 PHP 部署(一个小一个大),虽然它并不完美,但效果很好。 It also handles all of the code checkout / update, moving symlinks into place, and rolling back if something goes wrong.它还处理所有代码签出/更新,将符号链接移动到位,并在出现问题时回滚。

Once you have capistrano configured, all you have to do is something like:配置好 capistrano 后,您所要做的就是:

cap dev deploy 
cap prod deploy

Another option that I have explored for doing this is fabric .我为此探索的另一个选择是fabric Although I haven't used it, if I had to deploy a complex app again, I would consider it.虽然我没用过,但如果要重新部署一个复杂的应用程序,我会考虑的。 The interface is simple and straightforward.界面简单明了。

A third option you might take a look at thought its still in the early stages of development is gantry (pardon the self promoting).您可能会考虑的第三种选择是龙门式(请原谅自我推销),它仍处于开发的早期阶段。 This is something I have been working on out of frustration with using capistrano to deploy a PHP application in an environment with a lot of moving pieces.出于对使用 capistrano 在具有大量移动部件的环境中部署 PHP 应用程序的挫败感,我一直在努力解决这个问题。 Capistrano is great and works well for non PHP application deployments, but you still have to some poking around in the code to understand what is happening and tweak it to suit your needs. Capistrano 非常棒,适用于非 PHP 应用程序部署,但您仍然需要在代码中进行一些操作以了解正在发生的事情并对其进行调整以满足您的需求。 This is also why I suggest giving fabric a good look.这也是为什么我建议让面料看起来不错的原因。

I use a similar config now.我现在使用类似的配置。 Lamp + SVN + codeigniter + prd and dev servers.灯 + SVN + codeigniter + prd 和 dev 服务器。

I run the svn repos on dev.我在 dev 上运行 svn 存储库。 I checkout the repos into the root folder of the dev domain.我将 repos 检出到 dev 域的根文件夹中。 Then use a post-commit hook to update the root folder everytime any developer commits.然后在每次任何开发人员提交时使用提交后挂钩来更新根文件夹。

When we are happy and have fully tested the code I ssh into the prd server and rsync the dev root to the prd root.当我们很高兴并且已经完全测试了代码我 ssh 到 prd 服务器并将 dev 根同步到 prd 根。

Heres my solution for the different configs.这是我针对不同配置的解决方案。 Outside the root folder I have a config.ini file.在根文件夹之外,我有一个 config.ini 文件。 I parse the file in my codeigniter constants.php script.我在 codeigniter constants.php 脚本中解析文件。 This means that the prd and dev server can have separate settings without them ever being in the repos.这意味着 prd 和 dev 服务器可以有单独的设置,而无需它们在 repos 中。

If you want help with post-commit, rsync and ini code let me know.如果您需要有关提交后、rsync 和 ini 代码的帮助,请告诉我。

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

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